Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:06 02 May 2024 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 : DIM from query

Author Message
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 05:44am 13 Oct 2015
Copy link to clipboard 
Print this post

Is it possible to query a device and based on the response, set up my DIM statement for an array somewhere other than the beginning of the program?

Example, in my program, I query the device, Once queried, the device returns and says it has 20 objects (lets call them FRANKS) and each object has 1 - 30 things in it (lets call them BEANS). Once I get this information from the device, can I then put in my program...


OPTION BASE 1

GETINFO FRANK, BEANS

DIM OBJECTS(FRANKS, BEANS) <<<<<< this line

DO

STUFF
STUFF
STUFF

LOOP

SUB GETINFO FRANKS, BEANS
STUFF TO GET X
STUFF TO GET Y
STUFF
FRANKS = X
BEANS = Y
END SUB



Or do I have to DIM this in the beginning of the program with the max allowed franks and beans?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 05:56am 13 Oct 2015
Copy link to clipboard 
Print this post

Not a problem the attached is an example out of my sprite demo


' create a simple background to demonstrate that display memory is restored after a sprite is erased
cls rgb(0,89,41)
box 0,200,480,72,1,rgb(123,117,0),rgb(123,117,0)
box 0,0,480,100,1,rgb(123,255,255),rgb(123,255,255)
circle 400,50,30,,,rgb(yellow),rgb(yellow)
'
pwm 1,1000,50 'set the display backlight
'
read nsprites%,width%,height% 'read in the sprite data
'
' Dimension basic variables and the main arrays
'
DIM i%,j%,k%,l%,xold%,yold%
dim x%(numsprites%),y%(numsprites%),displaydata%(width%*height%/2,numsprites%),sprites%(width%*height%/2,nsprites%)
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 05:59am 13 Oct 2015
Copy link to clipboard 
Print this post

Excellent! Thank you Matherp!
 
Print this page


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

© JAQ Software 2024