How to check if Map() exists?

Just starting out? Need help? Post your questions and find answers here.
miskox
User
User
Posts: 95
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

How to check if Map() exists?

Post by miskox »

Here is a short example:

Code: Select all

Structure strSome
  SM.I
EndStructure
NewMap SomeMap.strSome()
SomeMap("1")\sm=1
SomeMap("2")\sm=0
SomeMap("3")\sm=3
Debug SomeMap("3")\sm
Debug SomeMap("4")\sm
Debug shows:

Code: Select all

3
0
Question: How can I determine if a map with that key does not exist? For SomeMap("4") I would like to get a status of 'does not exist/not defined or something' and not zero?

Thanks.
Saso
User avatar
mk-soft
Always Here
Always Here
Posts: 5334
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: How to check if Map() exists?

Post by mk-soft »

Code: Select all

Structure strSome
  SM.I
EndStructure
NewMap SomeMap.strSome()
SomeMap("1")\sm=1
SomeMap("2")\sm=0
SomeMap("3")\sm=3
If FindMapElement(SomeMap(), "3")
  Debug SomeMap("3")\sm
Else
  Debug "Not find"
EndIf
If FindMapElement(SomeMap(), "4")
  Debug SomeMap("4")\sm
Else
  Debug "Not find"
EndIf
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
miskox
User
User
Posts: 95
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

Re: How to check if Map() exists?

Post by miskox »

Thank you! Saved my day!

Saso
Post Reply