Hi All, I'm a BASIC hobby programmer. I've been playing around with GW BASIC for a while I'm trying to get my feet wet with TrueBasic. I have hit a snag trying to dimension an array. Seems simple enough, but I want to use a variable. As in "DIM A$(N)" I would have thought this was allowed but I get an error every time. Does anyone know how to do this?
Dimesion An Array
Hello Mike Cook
To Dimensiion an array, you're almost correct. But you cant use a variable when first "DIMMING" the array like you show: DIM a$(N). You must first use a numeric value where you used "N", then REDIM the array using a variable or other number:
Dim a$(0)
Let n=4
Mat Redim a$(n)
Same for multi dimensioned arrays. E.g., say you want an array with some number of rows, each with 4 columns:
DIM z(0,4)
rows=12
MAT REDIM z(rows,4)
There's a bit more than just this involved in using arrays, depending what you are trying to accomplish.
If you haven't already, it may be helpful to download the SILVER (or GOLD) pdf manual, which covers everything TB can do. Most of the explanations therein are good.
Hope this is helps. Any other questions, I will try to help.
Regards,
Mike C.
mcc Hey thanks Mike! I have the manual, I just got frustrated with it and decided to reach out. It occurred to me later in the evening to try something like that. Thanks also for your kind offer of further help. There will be more questions. I actually already have one, but I want to try something real quick before I bother anyone.