menuhistory not returning correct line number

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

menuhistory not returning correct line number

Post by jalz » Thu May 01, 2014 10:19 pm

Hi Guys,

I have an option menu which I've assigned a custom property to. I've got a number of values in the this custom property. When a user selects a value, I need to get the equivalent pair from my custom property. So if my user picks item 2 from the option menu, I would like the value second value from my custom property. I thought the menuhistory would return the line number, which I could then use to pick the relevant value from my custom property, but it only returns line number 1 regardless which value I choose from the the option menu. Any ideas where I've gone wrong, think I have the code correct.

Code: Select all

on MenuPick pItemName
   
   put pItemName into button "SupplierID"

   put the menuhistory of me into tLine 
   put line tLine of the cMyProperty of me into tValue
   put tValue into field "SupplierName"

end MenuPick
Thanks
Jalz

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: menuhistory not returning correct line number

Post by [-hh] » Thu May 01, 2014 10:39 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:06 pm, edited 1 time in total.
shiftLock happens

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: menuhistory not returning correct line number

Post by jalz » Thu May 01, 2014 11:39 pm

Hi Hermann,

The code I pasted was attached to an option button, hence the reason for using me. I've also used the actual target, i.e.
put the menuhistory of button "SupplierID" into tLine

However this is producing the same result as using me, just returns 1. I'm now wondering whether its the values of the option menu that are not formatted right to do this. Im populating the supplier id option menu with a sql query using the tab as the column delimiter and return as the row delimiter.

Jalz

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: menuhistory not returning correct line number

Post by [-hh] » Fri May 02, 2014 12:14 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:06 pm, edited 1 time in total.
shiftLock happens

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: menuhistory not returning correct line number

Post by jalz » Fri May 02, 2014 7:33 pm

Hi Hermann,
i tried a static option list(something with options manually put into by me) with the same custom property and code. That seemed to work fine, returning the corresponding menu history line number. I've tried this with Livecode 5.5 and I'm presently developing on 6.6.

Based on this, i'm swaying towards the way the data is being populated in the option menu. Here is my code I use to execute/populate the option menu, does anything obvious stand out? The delimiters all look like they should work, I've included the CR at the end of each value to make sure they contain a carriage return. Not sure I can check anything else :?

Code: Select all

on MouseDown
   If gConnID is a integer then
      
      put label of button "cb_supplier_id" into tSupplierID
      
      put "SELECT firstname, lastname, email FROM supplier_contact WHERE supplierID=" & tSupplierID into tTheSQLQuery
      put revDataFromQuery(tab, return, gConnID, tTheSQLQuery) into tTheComboBoxData 
      
      set itemdelimiter to tab
      
      put empty into tList1
      put empty into tList2
      
      repeat for each line tData in tTheComboBoxData 
         put item 1 of tData & " " & item 2 of tData & CR after tList1
         put item 3 of tData & CR after tList2
      end repeat
      
      If gList1 is not empty then
         set the text of button "cb_supplier_contact" to tList1
         set the cEmailProperty of button "cb_supplier_contact" to tList2
      else
         set the text of button "cb_supplier_contact" to "no contacts"
         set the cEmailProperty of button "cb_supplier_id" to empty
      end if
      
   end if
end MouseDown

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: menuhistory not returning correct line number

Post by [-hh] » Fri May 02, 2014 9:38 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:06 pm, edited 1 time in total.
shiftLock happens

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: menuhistory not returning correct line number

Post by jalz » Fri May 02, 2014 10:28 pm

Hi Hermann,

I think I have solved it, will do some more testing. SQLquery seems fine, the issue I believe was with the menu pick handler. I had the following like which I have commented out and it seems to be returning the correct values.

put pItemName into button "cb_supplier_contact"

More testing, to see if its working.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: menuhistory not returning correct line number

Post by [-hh] » Fri May 02, 2014 11:16 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:05 pm, edited 1 time in total.
shiftLock happens

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: menuhistory not returning correct line number

Post by jalz » Sat May 03, 2014 11:33 am

Thanks Hermann

All sorted now, I've rearranged the menu pick code so I grab the menu history as the first thing, and then populate the option menu with the correct value at the very end.

Jalz

Post Reply