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 / array problem

Author
Message
gsd
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location: London
Posted: 3rd Feb 2004 11:33
sure this is something to do with me not learning the basics properly. ive taken out all parts of code relevant:

why is it that...

dim model_paths$(1)
model_paths$(1) = "models\patrolboat_v1.1.x"

dim units#(max_units,15)
unit_class as integer : unit_class = 2
pboat as integer : pboat = 1

units#(1,unit_class) = pboat
load object model_paths$(units#(1,unit_class)),1

...will return garbage as the string whereas...

dim model_paths$(1)
model_paths$(1) = "models\patrolboat_v1.1.x"

dim units#(max_units,15)
unit_class as integer : unit_class = 2
pboat as integer : pboat = 1

units#(1,unit_class) = pboat
path = units#(1,unit_class)
load object model_paths$(path),1

....will work fine?

maybe i cant lookup an array based on the value of another one?

gsd
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 3rd Feb 2004 12:29
No, the problem is you can't refence an array using float variables, only integers.

i.e. this is ok:

a=1
print xyz$(a)

but this is not:

a#=1
print xyz$(a#)

Does 'unit' array need to hold float values. If not, the change from 'unit#' to 'unit'

Boo!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Feb 2004 14:26
Yeah ... what he said

Change this line:

load object model_paths$(units#(1,unit_class)),1

To this:

load object model_paths$(int(units#(1,unit_class))),1

Or better still, if you can, remove the need for the Units array to be floating point. There doesn't seem to be a need for floating-point here.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 3rd Feb 2004 16:22
What the ... an interloper! He's stolen my face! And he's not paying royalties!

More seriously, do what IanM said. Thats the fix.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Feb 2004 22:16
Perhaps he's your long-lost twin ...

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 4th Feb 2004 07:32
He does look awfully familiar... its almost like looking in a mirror.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home

Login to post a reply

Server time is: 2024-09-21 18:34:49
Your offset time is: 2024-09-21 18:34:49