Page 1 of 1
Structures with predefined member values
Posted: Fri Jan 27, 2012 8:24 am
by Franky
Hi there,
We have
And we have
Code: Select all
Structure dings
value.l
List Werte.l()
EndStructure
Global var.dings
var\value=5
Initializing the List needs setting values anyway, so, why not allow
Code: Select all
Structure dings
value.l=5
List Werte.l()
EndStructure
Global var.dings
Thanks for reading, discussing, implementing
Greetings
Franky
Edit: The old posting showed an example with Strings, but this needs memory allocation. So, it was removed with Numeric Values example.
And we have
Code: Select all
Structure dings
test.s
List Werte.l()
EndStructure
Global var.dings
var\test="String"
Initializing the List needs setting values anyway, so, why not allow
Code: Select all
Structure dings
test.s="String"
List Werte.l()
EndStructure
Global var.dings
Re: Structures with predefined member values
Posted: Fri Jan 27, 2012 4:23 pm
by c4s
Yes, I like that!
Re: Structures with predefined member values
Posted: Fri Jan 27, 2012 4:25 pm
by Little John
Franky wrote:Initializing the List needs setting values anyway, so, why not allow
Code: Select all
Structure dings
test.s="String"
List Werte.l()
EndStructure
Global var.dings
And why not even allow
Code: Select all
Structure dings
test.s = "String"
List Werte.l() = {1,2,3}
EndStructure
Global var.dings
Regards, Little John
Re: Structures with predefined member values
Posted: Fri Jan 27, 2012 5:56 pm
by STARGÅTE
-1
don't need it, a structure is a structure, and not a variable with pre-definition!
one way:
Code: Select all
Structure MyStructure
String.s
List Value.l()
EndStructure
With PreDefinition.MyStructure
\String = "String"
AddElement(\Value()):\Value() = 123
EndWith
Global Variable.MyStructure = PreDefinition
Debug Variable\String
FirstElement(Variable\Value())
Debug Variable\Value()
Re: Structures with predefined member values
Posted: Sat Jan 28, 2012 9:38 am
by Little John
I'm sorry, I don't want to hijack this thread, since what I'm proposing here actually is independent of structures. However, I think I should clarify what I previously wrote.
STARGÅTE wrote:one way:
Code: Select all
Structure MyStructure
String.s
List Value.l()
EndStructure
With PreDefinition.MyStructure
\String = "String"
AddElement(\Value()):\Value() = 123
EndWith
With
I did
not mean
Code: Select all
AddElement(\Werte()): \Werte() = 123
but this (pseudocode)
Code: Select all
ForEach element in sequence of constants
AddElement(\Werte()): \Werte() = element
Next
Something like this would come in very handy (also for arrays)!
Regards, Little John
Re: Structures with predefined member values
Posted: Tue Feb 21, 2012 12:47 pm
by Franky
Hey Little John, great idea, but it would be one step up.
I've corrected my example at the beginning as I currently only would need the predefined Members with values.
An imaginary roadmap could be like this:
Release 1:
Code: Select all
Structure Test
value.l=5 ; <-Works
string.s="Test"; <-Not implemented
List Parts.l()={1;2;3} <-Not implemented
EndStructure
=> No Memory allocations needed
Release 2:
Code: Select all
Structure Test
value.l=5 ; <-Works
string.s="Test"; <-Works
List Parts.l()={1;2;3} <-Not implemented
EndStructure
=> one single Memory allocation needed ; InitializeStructure needs to be handled with care
Release 3:
Code: Select all
Structure Test
value.l=5 ; <-Works
string.s="Test"; <-Works
List Parts.l()={1;2;3}; <-Works
EndStructure
=> Multiple memory allocation and a new Syntax is needed
So far
Franky