Are you doing this is in DBC or DBPro. Because with DBPro you can use types, which will make it easier. That way you can store everything in one array. If you don't have types, then you'll end up using several arrays or you'll have to use the data right away.
Since the number of entries is not static, you should put the number of entries on top of your file.
Then for loading the files with a variable, you should rename your files like this:
level1.txt
level2.txt
level3.txt
If you want to keep that name (like democity), just put it in the file. This also means you can replace the level strings in the data with levelnumbers. So now if you want to load a level, you'll need a variable which has stored the current level and load like this.
level=5
open to read 1,"level"+str$(level)+".txt"
...
..
.
Then the filedata itself. Let's say you don't have types. I think it's easiest if you store all the data in separate strings. That way you can read it(and maybe change it) when you open the file in notepad.
This way you'll get something like this. We call this file "level1.txt".
democity (name)
2 (# of entries)
5
8
"type_bank"
"Bank Of Scotland"
0
2 (level numbers instead of strings)
1 (level numbers instead of strings)
2
4
"type_hotel"
"Ritzi"
0
3 (level numbers instead of strings)
1 (level numbers instead of strings)
(end of file)
now you can read in the file like this.
level=1
open to read 1,"level"+str$(level)+".txt"
read string 1,name$ (read in the name)
read string 1,q$ : entries=val(q$) (read in the entries and convert the string to a number)
Then dim your arrays:
dim coords(entries,1)
dim type$(entries)
dim entryname$(entries)
dim strength(entries)
dim internallevel(entries)
dim level(entries)
And then start to read everything.
entry=0
repeat
entry=entry+1
read string 1,q$ : coords(entry,0)=val(q$)
read string 1,q$ : coords(entry,1)=val(q$)
read string 1,type$(entry)
read string 1,entryname$(entry)
read string 1,q$ : strength(entry)=val(q$)
read string 1,q$ : internallevel(entry)=val(q$)
read string 1,q$ : level(entry)=val(q$)
until file end(1)=1
close file 1
And then you have all the data and you can do with it what you like.
Kevil