Just starting out? Need help? Post your questions and find answers here.
-
Wolfram
- Enthusiast

- Posts: 604
- Joined: Thu May 30, 2013 4:39 pm
Post
by Wolfram »
How can I add an element to list inside a structure which is represented by a pointer?
Code: Select all
Structure personsStruc
firstName.s
lastName.s
List phoneNo.s()
EndStructure
dev.personsStruc
dev\firstName= "Bill"
Debug dev\firstName
*p = @dev\firstName
*dev.personsStruc = @*p
Debug *dev\firstName
AddElement( dev\phoneNo() )
dev\phoneNo() = "555"
;Here it crashes. How can I do this?
AddElement( *dev\phoneNo() )
macOS Catalina 10.15.7
-
mk-soft
- Always Here

- Posts: 6202
- Joined: Fri May 12, 2006 6:51 pm
- Location: Germany
Post
by mk-soft »
Wrong pointer assignment ...
Code: Select all
Structure personsStruc
firstName.s
lastName.s
List phoneNo.s()
EndStructure
Define dev.personsStruc
dev\firstName= "Bill"
Debug dev\firstName
*p = @dev\firstName ; <- Pointer to string firstname
Debug PeekS(*p)
*dev.personsStruc = @dev ; <- Pointer to structure data dev
Debug *dev\firstName
AddElement( dev\phoneNo() )
dev\phoneNo() = "555"
;Here it not more crashes.
AddElement( *dev\phoneNo() )
*dev\phoneNo() = "666"
ForEach dev\phoneNo()
Debug dev\phoneNo()
Next