CLEO Help Array example

CLEO related
Status
Not open for further replies.

WaTTi

Well-known member
Joined
Jan 4, 2015
Messages
260
Reaction score
8
Can someone give me a example?

like reading int from a file, etc.
 

MrChristmas

Expert
Joined
Jul 29, 2014
Messages
563
Reaction score
26
Simple Array for Activation

Code:
0AF0: 11@ = get_int_from_ini_file "CLEO/settings/mycleo/longtitle/butidontcare/hello/again/we/see/it/okey/lets/go/to/the/folder/where/i/will/store/my/cleo/config/now/config.ini" section "OPTIONS" key "KEY1" 
0AF0: 12@ = get_int_from_ini_file "CLEO/settings/mycleo/longtitle/butidontcare/hello/again/we/see/it/okey/lets/go/to/the/folder/where/i/will/store/my/cleo/config/now/config.ini" section "OPTIONS" key "KEY2" 

11@ and 12@ represents the caption for the string therefore you should not repeat it.
get_int_from_ini_file fallows the line of the name of the .ini file which you will create, you can name it anything altogether remember to set direction to CLEO\and place where you want to be stored, like; CLEO/settings/mycleo/longtitle/butidontcare/hello/again/we/see/it/okey/lets/go/to/the/folder/where/i/will/store/my/cleo/config/now/config.ini
section represents the caption from which it should read which I will show later, the same with key1/key2. They are very similar but section works like a heading and key1/key2 works like sub-heading.

This is how the .ini looks like now
Code:
[OPTIONS]
KEY1=
KEY2=

now it will store the 11@ and 12@ which we will use in the activation label.

Code:
:KEY
wait 10
if and
  key_down 11@
  key_down 12@
bla
bla
bla
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
hi idk if that's what you're asking for but to save/read big arrays you could use 0AD3 to create custom names of the "key". Here's an example of 2 functions which enable you to save and read arrays


Code:
//Example:
//0AB1: call_scm_func @save_to_ini 5 num 30@ xyz 1@ 2@ 3@ speed 4@ 
//
:save_to_ini
0AD3: 25@v = format "%d x" 0@
0AF3: write_float 1@ to_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v 
0AD3: 25@v = format "%d y" 0@
0AF3: write_float 2@ to_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v
0AD3: 25@v = format "%d z" 0@
0AF3: write_float 3@ to_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v
0AD3: 25@v = format "%d speed" 0@
0AF3: write_float 4@ to_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v
0AB2: ret 0



//Example:
//0AB1: call_scm_func @read_from_ini 1 num 30@ _retXYZ 1@ 2@ 3@ _retSpeed 10@
//
:read_from_ini
0AD3: 25@v = format "%d x" 0@
0AF2: 1@ = get_float_from_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v 
0AD3: 25@v = format "%d y" 0@
0AF2: 2@ = get_float_from_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v
0AD3: 25@v = format "%d z" 0@
0AF2: 3@ = get_float_from_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v
0AD3: 25@v = format "%d speed" 0@
0AF2: 4@ = get_float_from_ini_file "CLEO\INI\routeSave.ini" section "1" key 25@v
0AB2: ret 4 1@ 2@ 3@ 4@

"num 30@" is the variable stating which part of an array to save or read. If it's too slow you could check this mods' source for alternative way 
ugbase.eu/Thread-PRIVATE-Vehicle-Path-Recording-RELEASE
 
Status
Not open for further replies.
Top