Programmatically add option to menu.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Programmatically add option to menu.
Hi,
I've been trying to set up a new customer, and need to add the new customer code to a menu, so that the user can select the customer when raising an invoice, for example. I've tried to achieve this with all the types of menu in the tools pallette without success, and can't find anything in the lessons about it. Is it possible to do it, or will I have to resort to something entirely different ?
I've been trying to set up a new customer, and need to add the new customer code to a menu, so that the user can select the customer when raising an invoice, for example. I've tried to achieve this with all the types of menu in the tools pallette without success, and can't find anything in the lessons about it. Is it possible to do it, or will I have to resort to something entirely different ?
Re: Programmatically add option to menu.
Hi CAsba,
you need to modify "the text of btn yourmenuhere".
Example to add a new name to an existing menubutton:
If that is what you mean.
Best
Klaus
you need to modify "the text of btn yourmenuhere".
Example to add a new name to an existing menubutton:
Code: Select all
...
put the text of btn "your menu button here..." into tText
put CR & "Joe Average" after tText
set the text of btn "your menu button here..." to tText
...
Best
Klaus
Re: Programmatically add option to menu.
Thanks, Klaus. It works, but...
The first time the new line in the menu is immediately under the top line, it is on the next linr. Subsequent additions of options skip a line. I have removed the "CR &" from the line and still does it. I've also tried using a field instead of the variable tText.
If I'm stuck with this, is there an easy way to remove blank lines in the menu ?
The first time the new line in the menu is immediately under the top line, it is on the next linr. Subsequent additions of options skip a line. I have removed the "CR &" from the line and still does it. I've also tried using a field instead of the variable tText.
If I'm stuck with this, is there an easy way to remove blank lines in the menu ?
Re: Programmatically add option to menu.
Yes, the easy way is
Code: Select all
filter tText without empty
Re: Programmatically add option to menu.
Thanks SparkOut, that did it !
Re: Programmatically add option to menu.
Yep, use FILTER as SparkOut or check if the text = EMPTY!

Code: Select all
...
put the text of btn "your menu button here..." into tText
put "Joe Average" into tItem
if tText <> EMPTY then
put CR before tItem
end if
put tItem after tText
set the text of btn "your menu button here..." to tText
...
Re: Programmatically add option to menu.
Always think about how you would handle this in "real life"!
If you have a sheet of paper (tText), you would start to write at the top only if the sheet is empty.
If not, you would start to write on a new line!
If you have a sheet of paper (tText), you would start to write at the top only if the sheet is empty.
If not, you would start to write on a new line!
Re: Programmatically add option to menu.
What Klaus said.
But that said, it is indeed a little confusing because in a field, it is not obvious if a return character lurks at the end of a line. Returns are invisible.
Try this on a card with a field. In the message box:
Now:
You get two lines. But if you:
And then
You get one line of text.
You have to watch it.
Craig
But that said, it is indeed a little confusing because in a field, it is not obvious if a return character lurks at the end of a line. Returns are invisible.
Try this on a card with a field. In the message box:
Code: Select all
put "ABC" & return into fld 1
Code: Select all
put "ABC" after fld 1
Code: Select all
put "ABC" into fld 1
Code: Select all
put "ABC" after fld 1
You have to watch it.
Craig
Re: Programmatically add option to menu.
And just to sober you, if you:
and then ask for the number of lines in fld 1, you will get "1" as answer. The same as if you did not include the trailing return. A return char is just a character, oftentimes sitting invisibly at the end of a line.
But it does things we need it to. You just have to watch it if you are playing in that space.
Craig
Code: Select all
put "ABC" & return into fld 1
But it does things we need it to. You just have to watch it if you are playing in that space.
Craig