this would be my solution for this problem:
Code: Select all
Macro InsertValue(LList,value)
InsertElement(llist)
llist=value
EndMacro
; "with" is forbidden in macros.
Macro InsertValues(LList,v1,v2=,v3=,v4=,v5=,v6=,v7=,v8=,v9=,v10=)
InsertElement(LList)
LList#v1
LList#v2
LList#v3
LList#v4
LList#v5
LList#v6
LList#v7
LList#v8
LList#v9
LList#v10
EndMacro
NewList iTest.i()
InsertValue(iTest(),1)
InsertValue(iTest(),3)
InsertValue(iTest(),6)
InsertValue(iTest(),7)
Debug "iTest"
ForEach iTest()
Debug itest()
Next
Debug "--"
NewList sTest.s()
InsertValue(sTest(),"h")
InsertValue(sTest(),"o")
InsertValue(sTest(),"l")
InsertValue(sTest(),"e")
Debug "sTest"
ForEach sTest()
Debug stest()
Next
Debug "--"
Structure account
name.s
value.i
EndStructure
NewList aTest.account()
InsertValues(aTest(),\name="Hugo",\value=100)
InsertValues(aTest(),\name="Anna",\value=400)
Debug "aTest"
ForEach aTest()
Debug aTest()\name+" "+aTest()\value
Next
only problem, the LList in InserValues without a value generate programcode...
edit:
little Variant of InsertValues
Code: Select all
Macro MacroQuote
"
EndMacro
; "with" is forbidden in macros.
Macro InsertValues(LList,f1,v1,f2=,v2=,f3=,v3=,f4=,v4=,f5=,v5=)
InsertElement(LList)
CompilerIf MacroQuote#f1#MacroQuote<>""
LList\f1=v1
CompilerEndIf
CompilerIf MacroQuote#f2#MacroQuote<>""
LList\f2=v2
CompilerEndIf
CompilerIf MacroQuote#f3#MacroQuote<>""
LList\f3=v3
CompilerEndIf
CompilerIf MacroQuote#f4#MacroQuote<>""
LList\f4=v4
CompilerEndIf
CompilerIf MacroQuote#f5#MacroQuote<>""
LList\f5=v5
CompilerEndIf
EndMacro
Structure account
name.s
value.i
EndStructure
NewList aTest.account()
InsertValues(aTest(),name,"Hugo",value,100)
InsertValues(aTest(),name,"Anna",value,400)
Debug "aTest"
ForEach aTest()
Debug aTest()\name+" "+aTest()\value
Next