Page 1 of 1
add MacroA Or MacroA()
Posted: Tue Sep 27, 2016 1:08 am
by gurj
add MacroA Or MacroA()
add MacroA:
Code: Select all
Dim u.s(7)
u(3)="kk"
MacroA var(Array, value)
Array=value
EndMacroA
var(u(3), 8)
Debug kk;=8
======
Or add MacroA():
Code: Select all
Dim u.s(7)
u(3)="kk"
Macro var(Array, value)
MacroA(Array)=value
EndMacro
var(u(3), 8)
Debug kk;=8
Re: add MacroA Or MacroA()
Posted: Tue Sep 27, 2016 6:55 am
by HanPBF
Not a macro solution but an indirection.
Code: Select all
Structure Vars
map Content.i()
array Index.s(0)
endStructure
define *V.Vars = AllocateStructure(Vars)
redim *V\Index(7)
*V\Index(3) = "kk"
*V\Content(*V\Index(3)) = 8
debug *V\Content(*V\Index(3))
Re: add MacroA Or MacroA()
Posted: Tue Sep 27, 2016 7:48 am
by gurj
Thanks HanPBF ! might,This topic is bad.
my way:
Code: Select all
Global drs,kk,mbjw
Procedure StrToVal(s.s,value)
Select s
Case "drs":drs=value
Case "kk":kk=value
Case "mbjw":mbjw=value
EndSelect
EndProcedure
StrToVal("kk",8)
Debug kk;=8
Re: add MacroA Or MacroA()
Posted: Tue Sep 27, 2016 8:48 am
by Demivec
Even simpler:
Code: Select all
NewMap Vars.i()
;assign values
Vars("kk") = 8
Vars("mbjw") = 13
Vars("drw") = 4
;show selected values
Debug Vars("mbjw") ; =8
Debug Vars("kk") ; =13
Debug Vars("drw"); =4
;reassign a value
Vars("mbjw") = 59
;All vars:
ForEach Vars()
Debug MapKey(Vars()) + " = " + Vars()
Next
Another native way is to use Runtime (maybe more complex in some ways):
Code: Select all
Define one, two, three, half5.d, half3.d
Runtime one, two, three, half5, half3
SetRuntimeInteger("one", 8)
SetRuntimeInteger("two", 2)
SetRuntimeInteger("three", 13)
SetRuntimeDouble("half3", 3.5)
SetRuntimeDouble("half5", 5.25)
Debug GetRuntimeInteger("one") ; = 8
Debug GetRuntimeInteger("three") ; = 13
Debug GetRuntimeInteger("two") ; = 2
Debug GetRuntimeDouble("half3") ; = 3.5
Debug GetRuntimeDouble("half5") ; = 5.25
Re: add MacroA Or MacroA()
Posted: Tue Sep 27, 2016 11:03 am
by gurj
Thanks HanPBF and Demivec ! nice !
Re: add MacroA Or MacroA()
Posted: Sun Oct 02, 2016 1:36 am
by Lunasole
Here is some unique native way :3
The key len can't be longer that 4 chars in unicode mode.
Code: Select all
; On modern machines there is no more need to think about RAM!
Global Dim Stuff.i ('zzzz')
Stuff('nice') = 512
Debug Stuff('nice')
Re: add MacroA Or MacroA()
Posted: Sun Oct 02, 2016 11:43 am
by gurj
Thanks Lunasole very much ! nice!