Code: Select all
Structure Person
Name.s
Age.l
Country.s = "US"
EndStructure
Global People.Person
Code: Select all
Structure Person
Name.s
Age.l
Country.s = "US"
EndStructure
Global People.Person
Code: Select all
Structure Person
Name.s
Age.l
Country.s
EndStructure
Global DefaultPersonValue.Person: DefaultPersonValue\Country = "US" ;Define default for Person
Global People.Person = DefaultPersonValue ;Use default
Global OtherPeople.Person ;No default
Code: Select all
Structure MySquare
x.d ; default to 0.0 as usual
y.d ; default to 0.0 as usual
Width.d = 5.0
Height.d = 5.0
Scale.d = 1.0
EndStructure
A.MySquare
Debug A\Scale ; would be 1.0
*B.MySquare = AllocateStructure(MySquare)
Debug *B\Scale ; would be 1.0
*C.MySquare = AllocateMemory(SizeOf(MySquare))
Debug *C\Scale ; would be 0.0 - not yet initialized!
;
InitializeStructure(*C, MySquare)
Debug *C\Scale ; would be 1.0
;
ClearStructure(*C, MySquare)
Debug *C\Scale ; would be cleared to 0.0
+10000, this way we don't keep bumping requests for things that'll never happen.Rinzwind wrote: Sat Jun 07, 2025 12:47 pm ps it would be nice if Fred would just mark stuff as DISAGREE or AGREE and add to public flexible roadmap.
I agree with that, Fred (and I'm the one who started this thread, now 16 years ago, wow!Fred wrote: Sat Jun 07, 2025 4:06 pmSyntaxic sugar like this request have lower priority than things which can't be done otherwise.
Code: Select all
EnableExplicit
Structure TRect
x.i
y.i
w.i
h.i
EndStructure
Global TRect_default.TRect
With TRect_default
\x = 10
\y = 10
\w = 20
\h = 20
EndWith
Global MyRect.TRect = TRect_default
With MyRect
Debug \x
Debug \y
Debug \w
Debug \h
EndWith
Code: Select all
EnableExplicit
Structure TRect
ID.i
x.i
y.i
w.i
h.i
EndStructure
Procedure TRect_default(*Rect.TRect)
Static.i ID, x=10, y=10, w=20, h=20
With *Rect
\ID = ID
\x = x
\y = y
\w = w
\h = h
EndWith
ID +1
x +10
y +10
EndProcedure
Global MyRect1.TRect : TRect_default(MyRect1)
Global MyRect2.TRect : TRect_default(MyRect2)
With MyRect1
Debug \ID
Debug \x
Debug \y
Debug \w
Debug \h
EndWith
With MyRect2
Debug \ID
Debug \x
Debug \y
Debug \w
Debug \h
EndWith
Code: Select all
EnableExplicit
Structure TRect
ID.i
x.i
y.i
w.i
h.i
EndStructure
Procedure TRect_default(*Rect.TRect)
Static.i ID, x=10, y=10, w=20, h=20
With *Rect
\ID = ID
\x = x
\y = y
\w = w
\h = h
EndWith
ID +1
x +10
y +10
EndProcedure
Macro New_TRect_default(VarName)
VarName.TRect : TRect_default(VarName)
EndMacro
;Global MyRect1.TRect : TRect_default(MyRect1)
;Global MyRect2.TRect : TRect_default(MyRect2)
Global New_TRect_default(MyRect1)
Define New_TRect_default(MyRect2)
With MyRect1
Debug \ID
Debug \x
Debug \y
Debug \w
Debug \h
EndWith
With MyRect2
Debug \ID
Debug \x
Debug \y
Debug \w
Debug \h
EndWith