Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem creating a dynamic menu
Message
General information
Forum:
Visual FoxPro
Category:
Menus & Menu designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01157560
Message ID:
01157562
Views:
19
Claude,

The i and lcCxfer variables aren't evaluated within the ON SELECTION command until the user selects the bar from the menu. What you can do instead is pass the BAR() and PROMPT() values to the doftp method instead.
ON SELECTION BAR i OF &lcPopUpName DO doftp WITH BAR(),PROMPT()
Then in the doftp method, parse the prompt string accordingly.

Kurt
>I have the following program which correctly creates the menu and bar items (I have some extract variables defined I am using for debugging.
>
>** Get transfer definitions for a dynamic menu.
>
>LOCAL lnRecs, i, j
>LOCAL lcBarMsg, lcCxfer, lcClFile, lcCrFile, lcCros
>LOCAL lnlenCxfer, lcSelected, lcPopUpName
>LOCAL x
>LOCAL laTansdef[1]
>DECLARE laTansdef[1,4]
>
>SELECT  DISTINCT 		;
>			cxfer ,	;
>			clfile ,;
>			crfile ,;
>			cros ,	;
>			cmduser	;
>	FROM transfer 		;
>	WHERE !DELETED()	;
>		AND cmduser =	;
>		gcUserId	;
>	ORDER BY cxfer		;
>	INTO ARRAY laTansdef
>
>lnRecs	= ALEN(laTansdef)/4 - 1
>
>IF lnRecs = 0
>    =msgfrm('There are NO Transfer Definitions to add'  + ;
>	CHR(10) + SPACE(5) + 'to the Transfer Definitions nenu' ;
>		,'0',,'S','No Transfer Definitions',0,gnMsgWait)
>	RETURN .F.
>ENDIF
>
>lcPopUpName	= 'Definitions'
>
>DEFINE MENU TransferDefs FONT "Arial", 11 STYLE "I"
>DEFINE PAD TransferDefs OF TransferDefs PROMPT "Transfer Definitions"
>DEFINE POPUP &lcPopUpName FONT "Arial", 11 SHORTCUT
>
>ON PAD TransferDefs OF TransferDefs ACTIVATE POPUP &lcPopUpName
>
>FOR i = 1 to lnrecs
>
>	lcCxfer		= ALLTRIM(laTansdef[i,1])
>	lnlenCxfer	= LEN(lcCxfer)
>	lcClFile	= ALLTRIM(laTansdef[i,2])
>	lcCrFile	= ALLTRIM(laTansdef[i,3])
>	lcCros		= ALLTRIM(laTansdef[i,4])
>	
>	DO CASE
>		CASE !EMPTY(lcClFile) AND !EMPTY(lcCrFile)
>			lcBarMsg	= lcCxfer + " - Copy locate file " + lcClFile + ;
>				" to remote file " + ;
>				lcCrFile+ " on " + lcCros
>		CASE !EMPTY(lcClFile) AND  EMPTY(lcCrFile)
>			lcBarMsg	= lcCxfer + " - Copy locate file " + lcClFile + ;
>				"Prompt for remote file on " + lcCros
>		CASE  EMPTY(lcClFile) AND !EMPTY(lcCrFile)
>			lcBarMsg	= lcCxfer + " - Prompt for local file " +
>                           "and copy to remote " + ;
>				lcCrFile + " on " + lcCros
>		CASE  EMPTY(lcClFile) AND  EMPTY(lcCrFile)
>			lcBarMsg	= lcCxfer + " - Prompt for local and remoter files and copy to " + lcCros
>		OTHERWISE
>*!*				nop
>	ENDCASE
>	
>	DEFINE BAR i OF &lcPopUpName PROMPT lcBarMsg
>	ON SELECTION BAR i OF &lcPopUpName DO doftp WITH i , lcCxfer
>	
>ENDFOR
>
>ACTIVATE MENU TransferDefs
>
>My proplem is with the line
>
>ON SELECTION BAR i OF &lcPopUpName DO doftp WITH i , lcCxfer
>
>Currently all the doftp program does is display what it thinks i and lcCxfer are. The problem it displays the last value "lcCxfer = TESTEB" and i = 5. But there ar only 4 menu itesm.
>
>I tried setting j = 0 before the FOR loop and j = j + 1 to before the "ON SELECTION BAR" command, but the only difference is that j = 4 is displayed.
>
>If a use the debugger I can see i and lcCxfer change values.
>
>What am I doing wrong
>
>TIA for any help.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform