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 Question

Author
Message
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 5th Apr 2009 23:05 Edited at: 6th Apr 2009 00:26
EDIT: Hi can a MOD rename this to Array Test

Hi there. Im not near a PC with DBPro on so this is just from memory:

Here is a simple program with arrays and I would just like to know if it was the right concept? Is it right, wrong and why? Anyhows here it is:



Well thats it, Like I said im not a machine with DBPro on so it's probably all wrong. Anyway this is just off the top of my head so...What do you think?

Jack

TheCleverGuyz
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 5th Apr 2009 23:13
Looks OK from what I can tell, but you're missing a few things:

*Each of your IF statements needs its own ENDIF unless you are using it in conjunction with THEN.
*Endif doesn't work on GOSUB labels. You will need to use RETURN.
*When referencing an array, you must refer to it you declared it (name-wise). For example, you declared your People array like this: DIM People$(1). But you later say People(0) = "Bob". Don't forget the $ sign

Other than that it looks okay at first glance. Good luck testing it!

<---Spell casting battle game!
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 5th Apr 2009 23:20
Is that better?

TheCleverGuyz
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 5th Apr 2009 23:46
No, sorry if I was unclear... I meant that if you DIM your array as People$(1), you need to say People$(0) = "Bob", not just People(0) = "Bob" if you want to put something in the array. . Now it makes less sense than before...

<---Spell casting battle game!
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 5th Apr 2009 23:56 Edited at: 6th Apr 2009 00:27
Oh, ok. I changed the array to: Dim People(1) as String is this better?

EDIT: Ok I got on a machine with DB on and changed it round so it works. But only bob's characteristics work Pats do not? Whats the problem?

TheCleverGuyz
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 6th Apr 2009 00:33
I have made it cleaner but Pat's Chars still won't work



TheCleverGuyz
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 6th Apr 2009 00:37
Well, your Bob and Pat subroutines have no return.

That's what they WANT you to think...
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 6th Apr 2009 01:39
Why not use UDT arrays? Much neater than needing to have a separate array for each person.

Login to post a reply

Server time is: 2024-11-24 09:56:35
Your offset time is: 2024-11-24 09:56:35