Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:23 02 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Pass an Array *name* to a SUB?

Author Message
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 383
Posted: 06:54am 23 Apr 2025
Copy link to clipboard 
Print this post

Is there any way to pass the name of an array to a SUB? I don't want to pass the array itself but rather the name of the array so I can use a single call that selects between MATH M_PRINT and MATH V_PRINT without worrying whether the table in question is an array or a vector.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7464
Posted: 07:45am 23 Apr 2025
Copy link to clipboard 
Print this post

Pass both but use the zeroeth value or a flag to indicate which task you want?

I can't se how you could pass a name other than as a string. If you did that the string itself could be the array, but you may need to copy it into a proper local array to manipulate it.
Edited 2025-04-23 17:47 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1121
Posted: 07:20pm 23 Apr 2025
Copy link to clipboard 
Print this post

Could you use the Bound function to determine the dimensionality (?) of the passed array?
Visit Vegipete's *Mite Library for cool programs.
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 383
Posted: 08:50pm 23 Apr 2025
Copy link to clipboard 
Print this post

  vegipete said  Could you use the Bound function to determine the dimensionality (?) of the passed array?


Hmmm. That might work. I'll investigate. Thanks!
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 04:35pm 24 Apr 2025
Copy link to clipboard 
Print this post

pass it as string and then
single :Execute "Dim " + yourstring$ + "(" + Str$(your_value) + ")"
Two dimensional: Execute yourstring + "(" + Str$(your_value) + "," + Str$(your_value) + ") = " + Str$(your_value)


If you want to see what your code is doing replace the execute with print.
Edited 2025-04-25 02:47 by dddns
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025