Map to file: Difference between revisions
Jump to navigation
Jump to search
imported>StDoodle m Blanked the page |
imported>StDoodle No edit summary |
||
Line 1: | Line 1: | ||
{{ | |||
#vardefine:name|map_to_file}}{{ | |||
#vardefine:return_type|boolean}}{{ | |||
FunctionPage| | |||
name={{#var:name}}| | |||
function_category=Miscellaneous| | |||
function1={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|aggregate|map_to_save}}| | |||
parameter2={{Param|string|file_to_save}}| | |||
}}| | |||
function2={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|aggregate|map_to_save}}| | |||
parameter2={{Param|string|file_to_save}}| | |||
parameter3={{Param|boolean|condition}}| | |||
p1desc={{Pspan|file_to_save}} is the filename to save to| | |||
p2desc={{Pspan|map_to_save}} is the map to save data from| | |||
p3desc={{Pspan|condition}} is an (optional) condition that must be met for the function to act| | |||
}}| | |||
function_description=Loads data to the {{pspan|map_to_fill}} from a saved {{pspan|file_to_load}} in your KoLmafia "data" directory. If {{pspan|condition}} is supplied, it must evalute to true in order for the function to proceed. This function returns the operations success (if {{pspan|condition}} is supplied, and evaluates to false, this function returns true). If {{pspan|map_to_fill}} has not been initialized, this function will abort (as oppossed to returning false).| | |||
code1={{CodeSample| | |||
title=Code Sample| | |||
description=This sample loads a simple map that includes item names keyed by a number.| | |||
code= | |||
<syntaxhighlight> | |||
string [int] my_list; | |||
file_to_map( "SavedList.txt" , my_list); | |||
for i from 0 to (count(my_list) - 1) { | |||
print( "At index: " + i + " We find: " + my_list[i] ); | |||
} | |||
</syntaxhighlight>| | |||
moreinfo= | |||
If the file "SavedList.txt" had the following: | |||
<pre> | |||
0 StDoodle | |||
1 Grotfang | |||
</pre> | |||
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|}}| | |||
}} |
Revision as of 01:24, 11 March 2010
Function Syntax
boolean map_to_file(aggregate map_to_save ,string file_to_save )
boolean map_to_file(aggregate map_to_save ,string file_to_save ,boolean condition )
- file_to_save is the filename to save to
- map_to_save is the map to save data from
- 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 from 0 to (count(my_list) - 1) {
print( "At index: " + i + " We find: " + my_list[i] );
}
If the file "SavedList.txt" had the following:
0 StDoodle 1 Grotfang
Then the results would be:
At index: 0 We find: StDoodle At index: 1 We find: Grotfang
See Also