Skip to content

Structs-Field can not be modified via Struct-Methods #684

@GWRon

Description

@GWRon

I tried to manipulate/modify a struct field from within (in my case to retrieve current max2d stuff like resolution, scale, ...) but somehow it is is only visible "inside" the method

SuperStrict
Framework Brl.StandardIO

Struct STest
	Field x:Int
	
	Method Fill()
		Local newX:Int
		FillX(newX)
		x = newX
		Print "Fill() x="+x
	End Method

	Method Modify()
		x = 30
		Print "Modify() x="+x
	End Method

End Struct

Function FillX(value:Int Var)
	value = 20
End Function


Local tests:STest[10]
tests[0].Fill()
Print "tests[0].x = " + tests[0].x
tests[0].Modify()
Print "tests[0].x = " + tests[0].x

Print "Set x=50"
tests[0].x = 50
Print "tests[0].x = " + tests[0].x

Output

Fill() x=20
tests[0].x = 0
Modify() x=30
tests[0].x = 0
Set x=50
tests[0].x = 50

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions