Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / right... a prob (like always)

Author
Message
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 04:12 Edited at: 19th Mar 2003 04:20
heres my code to load my map data from an array but for some reason it creates an error "Runtime Error at Line X. Array Name is not Valid."
-----------------------------------------------
function loadmap(filename$,size)
dim map$(size,size)
Line x-->load array "w.tmp",map$(256,256)
open to read 1,filename$
for y=1 to size
for x=1 to size
read byte 1,tmp
map$(x,y)=chr$(tmp)
next x
next y
close file 1
endfunction
----------------------------------------------
now line x is copied from a line earlier in the program loading the same array
thats works fine...
EDIT: after more testing ive figuresd out that line x is either the one marked off or the one right after it...
EDIT: on more testing ive determined that it is the line after the marked off one...wierd
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 04:20
regardless of your arrays dimensions try using load and save with a zero at the index of array paramters

load array "w.tmp",map$(0)
save array "w.tmp",map$(0)

matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 04:21
the problem with that is that you have to declare the array first or the load doesnt work
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 04:25
you created your array in your function the line before this command and therefore you must know what local/global space that is.

I cant help you if your looking to answer the solution with more diatribe.

matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 04:44
umm right... all i was saying is that i declare my array as 500 items (example) then i cant refer to it as an array of 0 items

anyways its redundant the problem is in the open to read line
cant figure out why
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 04:57
regardless of your arrays dimensions

try using load and save array commands

with a zero

load array "w.tmp",map$(0)
save array "w.tmp",map$(0)


my arrays are 2 dimensions and Ive obscured there real names but have a look at what i use

load array XXXXXXX$,XXXXX(0)

matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 05:17
k thx for your help
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 05:21
unfortunately ive run into another array problem
and indi i meant no sarcasm ur help worked quite well

so heres the new prob


its returning the error Array accessed out of bounds on the print map$(ii,i) command...
dont know how this is possible because the array was created with the same dimensions as the for-do loop... its probly something stupid i just dont see
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 05:41
try this example mate

maybe its easier just to speak in code




indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 05:46
oops


you should remove these lines

for x = 1 to 5
for y = 1 to 5
mapdata(x,y) = rnd(100)+1
next x
next y


i accidentally left that bit in but the next paragraph overwrites it so just remove it as its not required.

matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 06:03
ummm that doesnt really help me too much
good work on the code though it works perfectly

the biggest problem im having is that the code im working on right now is in an include file first of all
and i already have all the data for my arrays, its a 256x256 square of chars that make up my map data

thats why im using all of the save/load things that were suggested to me

but anyways for some reason when i create the array it ends up bieng smaller than what i want it to be...
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 06:12
try and remove it from the include and keep it in the main until u find out what is not allowing a global/local access then keep these things in main and the rest in includes

other than that im not sure mate

matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 06:38
cool... ya i got everything working fine when i hard code the size of the arrays... i only run into problems when i use a variable for the size of the array... ill figure out what i did wrong soon enough

thanks for the help eh
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 08:09
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 16:35
ok so i got it to work using vars... this is wierd

you know i was making the "important" array using another "array" for the dimensions... for some reason db dont like that so i have to create a var to store the vale of the dimension array (its only an array so i can save it and access it elsewhere)

like this


thats the only way it will work for me
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Mar 2003 16:46
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 19th Mar 2003 18:38
ya like i said before its probably something stupid im not doing right but it works now so thats ok
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 20th Mar 2003 05:27
didnt DBP have a problem with an array of zero.

maybe an older version like 3.1 had a small issue with an array of a zero space.

Login to post a reply

Server time is: 2024-11-24 05:25:33
Your offset time is: 2024-11-24 05:25:33