File to map: Difference between revisions
Jump to navigation
Jump to search
imported>StDoodle No edit summary |
imported>StDoodle No edit summary |
||
Line 38: | Line 38: | ||
string [int] my_list; | string [int] my_list; | ||
file_to_map( "SavedList.txt" , my_list); | file_to_map( "SavedList.txt" , my_list); | ||
for i 0 to count(my_list) { | |||
print( "We | print( "At index: " + i + " We find: " + my_list[i] ); | ||
} | } | ||
</syntaxhighlight>| | </syntaxhighlight>| | ||
Line 49: | Line 49: | ||
</pre> | </pre> | ||
Then the results would be: | Then the results would be: | ||
<pre> | |||
At index: 0 We find: StDoodle | |||
At index: 1 We find: Grotfang | |||
</pre> | |||
}}| | }}| | ||
see_also={{SeeAlso|map_to_file|}}| | see_also={{SeeAlso|map_to_file|}}| | ||
}} | }} |
Revision as of 01:02, 11 March 2010
Function Syntax
boolean file_to_map(string file_to_load ,aggregate map_to_fill )
boolean file_to_map(string file_to_load ,aggregate map_to_fill ,boolean condition )
- file_to_load is the filename to load from
- map_to_fill is the map to populate with data
- condition is an (optional) condition that must be met for the function to act
Loads data to the map_to_fill from a saved file_to_load in your KoLmafia "data" directory. If condition is supplied, it must evalute to true in order for the function to proceed. This function returns the operations success (if condition is supplied, and evaluates to false, this function returns true). If map_to_fill has not been initialized, this function will abort (as oppossed to returning false).
Code Sample
This sample loads a simple map that includes item names keyed by a number.
string [int] my_list;
file_to_map( "SavedList.txt" , my_list);
for i 0 to count(my_list) {
print( "At index: " + i + " We find: " + my_list[i] );
}
If the file "SavedList.txt" had the following:
StDoodle 0 Grotfang 1
Then the results would be:
At index: 0 We find: StDoodle At index: 1 We find: Grotfang
See Also