I'm trying to save an Array using Matrix1Util dll's. I'm not even sure I'm doing this right as I couldn't find a lot of data on the use of SAVE ARRAY TO DATAFILE. I'm relatively new to working with arrays as all my previous DBP stuff has been incredibly simple but now I'd like to work with files and thought this would be a god start.
Anyway, on to the problem. I have my code laid out as below.
Note: I'm aware SAVE ARRAY doesn't allow me to save the data as I want it, so I'm trying SAVE ARRAY TO DATAFILE.
type MonstersType
name$ as string
health as integer
attack as integer
defence as integer
evasion as integer
af as integer
image as integer
eq as integer
endtype
dim monsters(3) as MonstersType
`dummy
monsters(0).name$ = "dummy"
monsters(0).health = 1
monsters(0).attack = 1
monsters(0).defence = 1
monsters(0).evasion = 1
monsters(0).af = 1
monsters(0).image = 1
monsters(0).eq = 1
`Rat
monsters(1).name$ = "Rat"
monsters(1).health = 5
monsters(1).attack = 5
monsters(1).defence = 1
monsters(1).evasion = 1
monsters(1).af = 0
monsters(1).image = 21
monsters(1).eq = 0
`Snake
monsters(2).name$ = "Snake"
monsters(2).health = 10
monsters(2).attack = 6
monsters(2).defence = 2
monsters(2).evasion = 1
monsters(2).af = 0
monsters(2).image = 22
monsters(2).eq = 0
`Goblin
monsters(3).name$ = "Goblin"
monsters(3).health = 15
monsters(3).attack = 7
monsters(3).defence = 3
monsters(3).evasion = 2
monsters(3).af = 0
monsters(3).image = 23
monsters(3).eq = 1
open datafile to write 1, "data/monsters.dat"
save array to datafile monsters(3), 1
close datafile 1
Now once I launch my program it simply crashes out (a Windows style, want to report error one). I've tried adding some debug stuff in there such as;
exist = DATAFILE EXIST (1)
print exist
Still just crashes without doing anything. So, where am I going wrong? Is simply not possible to write the type of data I'm trying to or am I using the command wrong?
On a side note is possible to do something like this
`File: monster.dat
`Monsters should be listed as following
`Name | Health | Attack | Defence | Evasion | AF | Image | EQ
rat,5,5,1,1,02,1,0
snake,10,6,2,1,0,22,0
goblin,15,7,3,2,0,23,1
and then load that file in a way to get my data like so ready for use?
`Rat
monsters(1).name$ = "Rat"
monsters(1).health = 5
monsters(1).attack = 5
monsters(1).defence = 1
monsters(1).evasion = 1
monsters(1).af = 0
monsters(1).image = 21
monsters(1).eq = 0