icon315
Member
I am trying to make it so that you can add items to a file. this is what i have so far.
I got the actual saving works. But as soon as i get to the page it saves int 0. then when i try to submit it overwrites the page.
This is the most reason test. I was trying to fix the overwrite problem.
CODE
CLI
this is what the .txt file before
and after i ran the script
and when i submitted a the number 1565 ( first i reset the file)
PHP:
int itm;
string [int] my_items;
file_to_map( "My_Items.txt" , my_items);
attr("size=4 maxlength=4");
itm = write_field("", "itemnum", "Item Number: ").to_int();
write_button("itemnumber", "Add");
string [int] new_item;
new_item [(count(my_items) + 1)] = itm ;
if (map_to_file( new_item , "My_Items.txt" ))
print( "Your item were saved successfully." );
else
print( "There was a problem saving your item." );
This is the most reason test. I was trying to fix the overwrite problem.
CODE
PHP:
int itm;
string [int] old_items;
file_to_map( "My_Items.txt" , old_items);
attr("size=4 maxlength=4");
itm = write_field("", "itemnum", "Item Number: ").to_int();
write_button("itemnumber", "Add");
string [int] new_item;
for i from 0 to (count(old_items)) {
new_item [count(old_items)] = old_items[i];
}
new_item [(count(old_items) + 2)] = itm ;
if (map_to_file( new_item , "My_Items.txt" ))
print( "Your item were saved successfully." );
else
print( "There was a problem saving your item." );
Code:
Your item were saved successfully.
Begin index -1 out of bounds (relay_Daily_Info.ash, line 134)
this is what the .txt file before
Code:
0 194
1 1450
and after i ran the script
Code:
2
4 0
and when i submitted a the number 1565 ( first i reset the file)
Code:
2
4 1565
Last edited: