Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array Quesion: What is being assigned here?
#1
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
Reply
#2
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
Reply
#3
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.
Reply
#4
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
Reply
#5
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...
Reply
#6
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! Smile
Joe
Reply
#7
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. Wink

(Oracle: can I change my post rank to something else?)
Reply
#8
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 Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)