Posts: 5
Threads: 2
Joined: Sep 2004
I have some old code I am trying to understand.
There is an array:
DIM VAP1(5000)
(it does not say the type) and later it is assigned as follows:
VAP1 = 0
What is this doing? Is it setting every element in the array to zero or the first element of the array to zero?
Joe
Posts: 383
Threads: 14
Joined: Mar 2004
Yes it's setting every element to zero, but I don't think it's necessary. I believe the default type of an array is single
Posts: 1,752
Threads: 21
Joined: Jun 2002
VAP1() and VAP1 are two different things. One is a 5001 or 5000 (depending on your option base) element array, the other is just a variable. Setting VAP1 = 0 has no effect on the VAP1() array.
Posts: 5
Threads: 2
Joined: Sep 2004
Okay, now I have 2 conflicting answers. Which one is right? Since variables can be declared on the fly in QBASIC, I don't know how to tell the difference between VAP1(5000) and VAP1.
Someone please be a tie-breaker.
Joe
Posts: 1,752
Threads: 21
Joined: Jun 2002
Whenever you reference an array in QB, you must use (). So if you don't see any parenthesis after the name, it's not an array. That's how you tell the difference.
Of course, if you don't believe me, you could always try it yourself and see...
Posts: 5
Threads: 2
Joined: Sep 2004
Thanks Nathan! I'll take your advice. By the time I finish re-writing all this code and try to do my first test run, I want as few a bugs as possible!
Joe
Posts: 1,752
Threads: 21
Joined: Jun 2002
3 exceptions to this rule: ERASE, UBOUND and LBOUND. (Because you must use an array with these statements/functions, () are not required.)
My name is Jon, btw.
(Oracle: can I change my post rank to something else?)
Posts: 3,522
Threads: 189
Joined: Dec 2003
Joe, the na_th_an under the name is the post rank, long time ago everyone was impressed with, just na_th_an's post count, so they made a rank, when you get a number of posts, it will appear under your name.
You can ask for a custom one, like mine