Problem with List [ AddElement( *dev\phoneNo() ) ]

Just starting out? Need help? Post your questions and find answers here.
Wolfram
Enthusiast
Enthusiast
Posts: 604
Joined: Thu May 30, 2013 4:39 pm

Problem with List [ AddElement( *dev\phoneNo() ) ]

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
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Problem with List [ AddElement( *dev\phoneNo() ) ]

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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply