Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clear all variables
#8
Use 100 separate global variables for a single task? Of course better add all related variables to a type or several types.

Macro
Code:
Copy      Help
;declare a type with all related variables
type MY100VARIABLES
,intvar1 intvar2 and so on
,str'strvar1 str'strvar2 and so on
,and so on
,In types you also can use fixed size arrays, dynamic arrays, and other types, like the following
,str'a[50] ARRAY(str)a2 RECT'r

;declare 1 global variable of that type. It contains all the variables declared in the type statement above
MY100VARIABLES+ g_var

;use the variables
g_var.intvar1=10
g_var.strvar1="string1"
g_var.a[0]="string2"
g_var.r.bottom=100
g_var.a2.create(5)
out g_var.strvar1
out g_var.a[0]
out g_var.intvar1
out g_var.r.bottom
out g_var.a2.len
;...
;clear all variables in g_var
MY100VARIABLES empty; g_var=empty

out g_var.strvar1
out g_var.a[0]
out g_var.intvar1
out g_var.r.bottom
out g_var.a2.len


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)