Coding

 Reply to this postStart new topic

Searching for file

HeresOtis
post Jul 3 2012, 09:30 PM
Post #1


Newbie In Training

Posts: 17
Joined: 23-November 11



For my mod, I will create a folder in CLEO folder, so the directory will be CLEO\SAPDFR\Addons. This is where people can create addons for my mod and add them in the folder so they can be executed from the main cleo script.

Can someone write a sample script for me that shows how to get the file names in the directory and start that script?

Also, is it possible for a CLEO script to get the name of the directory it's in?

This post has been edited by HeresOtis: Jul 3 2012, 09:39 PM
Go to the top of the page
 
+Quote Post
badboy
post Jul 3 2012, 11:29 PM
Post #2


Trained Member

Posts: 76
From: Nederland, NL
Joined: 1-May 12



So you don't know the file name and directory? Can't you just let people merge it into one known file? AFAIK it isn't possible to get the directory in cleo. You can get the file name though.

This post has been edited by badboy: Jul 3 2012, 11:30 PM
Go to the top of the page
 
+Quote Post
Deji
post Jul 4 2012, 12:26 AM
Post #3


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Check this out: http://gtagmodding.com/opcode-database.php?opcode=0AE6


--------------------
Go to the top of the page
 
+Quote Post
HeresOtis
post Jul 4 2012, 12:31 AM
Post #4


Newbie In Training

Posts: 17
Joined: 23-November 11



DK22Pac gave me a sample on GTAF:
CODE
if
0AE6: 0@ = find_first_file "CLEO\IVLM\*.lm" get_filename_to 1@v //IF and SET
then
repeat
0AD3: 5@v "IVLM\%s" 1@v
0A92: create_custom_thread 5@v
until 8AE7: not 1@v = find_next_file 0@ //IF and SET
0AE8: find_close 0@
end


Can someone answer this though: Also, is it possible for a CLEO script to get the name of the directory it's in?
Go to the top of the page
 
+Quote Post
badboy
post Jul 4 2012, 10:41 AM
Post #5


Trained Member

Posts: 76
From: Nederland, NL
Joined: 1-May 12



You already have the directory. That code doesn't search in subdirectories.

This post has been edited by badboy: Jul 4 2012, 12:49 PM
Go to the top of the page
 
+Quote Post
Deji
post Jul 4 2012, 11:01 AM
Post #6


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



What do you mean? If you know it's gonna be in "CLEO\IVLM" then you shouldn't need to get the name of the directory... 0AE6 doesn't retrieve files in subdirectories, but it does retrieve subdirectories themselves. So if you want subdirectory searching (it's gonna be tricky), you have to append 1@v (like so: "CLEO\IVLM"+ 1@v +"*.lm") to the search path, then perform a new search as a subroutine.


--------------------
Go to the top of the page
 
+Quote Post
HeresOtis
post Jul 17 2012, 05:46 PM
Post #7


Newbie In Training

Posts: 17
Joined: 23-November 11



How come this keeps on looping? I did a test with it and it creates the scripts, but after the last file, it goes back to the first file and creates them over and over again. I use it as a gosub command.

CODE
:CreateRoutinePatrolScripts
if
0AE6: 0@ = find_first_file ROUTINEPATROL_Directory get_filename_to 4@v //IF and SET
then
repeat
0AC8: 8@ = allocate_memory_size 50
0AD3: 8@ "SAPDFR\RoutinePatrol\%s" 4@v
0A92: create_custom_thread 8@
until 8AE7: not 4@v = find_next_file 0@ //IF and SET
0AE8: find_close 0@
0AC9: free_allocated_memory 8@
end
return
Go to the top of the page
 
+Quote Post
LINK/2012
post Jul 17 2012, 07:44 PM
Post #8


I will kill you

Posts: 126
Joined: 13-May 11



QUOTE
How come this keeps on looping? I did a test with it and it creates the scripts, but after the last file, it goes back to the first file and creates them over and over again. I use it as a gosub command.

Don't know, but you're leaking memory in the repeat...until loop.
You're allocating a new memory block on each loop iteration and only free the last allocated block.
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: