Re : popup menu in map basic

601 views
Skip to first unread message

albert agasthiyan

unread,
Aug 6, 2013, 1:53:24 AM8/6/13
to mapi...@googlegroups.com
hai 

I am new in MapBaisc  , I  want add value to popup menu  from table and with out duplicate value .


Thomas Bacon

unread,
Aug 6, 2013, 4:00:56 AM8/6/13
to mapi...@googlegroups.com

Hi Albert,

 

Unfortunately, you can’t directly populate a popupmenu from a column in a table. What you can do however is populate an array with the values you want and then use that array to populate the popupmenu. Something like the below will work for a column of character type (just change the array and strSelection variables to the appropriate type if your column is not a character type):

 

Include "MapBasic.def"

 

Declare Sub Main

 

 

Sub Main

      

Dim strValues() as String         '// Dim your array

Dim i as Integer                  '// Array counter

Dim iSelection as Integer         '// Index of selection from popupmenu

Dim strSelection as String        '// String variable to store selected value

 

       Select yourColumn from yourTable Group By yourColumn into UniqueList       '// Select unique values of yourColumn into table UniqueList

      

       If TableInfo(UniqueList, TAB_INFO_NROWS) > 0 then      '// Check that selection returned more than 0 rows

 

              Redim strValues(TableInfo(UniqueList, TAB_INFO_NROWS)) '// Resize the array to the number of returned rows

              i = 0

             

              '// Populate array with unique values

              Do while Not EOT(UniqueList)

                     i = i + 1

                     strValues(i) = UniqueList.yourColumn                  

              Loop

 

       End If

 

       Dialog

              Title "A Dialog Box"

                     Control PopUpMenu

                           Position 4, 10

                           Width 80

                           Title From Variable strValues()          '// Use array to populate values in popupmenu

                           Into iSelection                          '// Store index of selected value into iSelection when ok button is clicked

                     Control OkButton

                           Position 10, 28

                          

                           

       If CommandInfo(CMD_INFO_DLG_OK) then     '// Check that the OK button was clicked in dialog box

             

              strSelection = strValues(iSelection)     '// Get selected value from array

             

       End If

 

 End Sub

 

Hope this helps,

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
 
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



Mouchel logo

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

Bo Victor Thomsen

unread,
Aug 6, 2013, 4:13:38 AM8/6/13
to mapi...@googlegroups.com
Den 06-08-2013 10:00, Thomas Bacon skrev:

Do while Not EOT(UniqueList)

                     i = i + 1

                     strValues(i) = UniqueList.yourColumn                  

              Loop


The loop should look like this:


Fetch first from
UniqueList
Do while
Not EOT(UniqueList)

  i
= i + 1
  strValues(i)
= UniqueList.yourColumn
  Fetch Next from UniqueList
Loop


Regards
Bo Victor Thomsen
Aestas-GIS
Denmark

Thomas Bacon

unread,
Aug 6, 2013, 4:14:48 AM8/6/13
to mapi...@googlegroups.com

Indeed it should! Time for a coffee I think…

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

 

--

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
 
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Albert Agasthiyan

unread,
Aug 6, 2013, 8:12:25 AM8/6/13
to mapi...@googlegroups.com

Thanks Tom Bacon , Its working fine 

--
Albert Agasthiyan M.Sc.,M.Tech.,
GIS Engineer
ADH & GULF COMPUTER EST,
Abu Dhabi, UAE

 0556692191 (M),
 

DMcE

unread,
Aug 7, 2013, 4:58:10 AM8/7/13
to mapi...@googlegroups.com
Does a Do...Loop have an advantage over a For...Next here? I would write it like this:
 
For i = 1 to Tableinfo(Uniquelist, TAB_INFO_NROWS) 
  Redim strValues(i)
  Fetch rec iLoop from Uniquelist
  strValues(i)  = Uniquelist.yourcolumn
Next
 
I'm just wondering which method is more efficient or if it is a matter of personal taste.
 
 
David.

Thomas Bacon

unread,
Aug 7, 2013, 5:02:50 AM8/7/13
to mapi...@googlegroups.com

According to this: http://bytes.com/topic/access/insights/797078-next-vs-do-loop-winner

 

… For… Next is the winner by about 50%. I tend to chop and change between the two with no particular thoughts about why, just whatever I happen to use at the time. I think I might stick with For… Next in most cases from now on!

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

 

From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of DMcE


Sent: 07 August 2013 09:58
To: mapi...@googlegroups.com

--

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
 
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages