4DToday.com
Home Directory Classifieds Reference Archives
Site Info
About 4DToday.com
Contact Us
Version française
Resources
4D
4D, Inc.
4D International
4D Wiki
4D Partner Central
4D Beginner's Center
4D Online Documentation
4D 2004 Example Applications
4D Example Databases
4D BugDisplayer
4D, Inc. Training
Message Lists
4D Mailing Lists
4D Tech Google Group
iNUG Archives (Nabble)
iNUG Archives (Gmane)
iNUG Message Index
Other
4D Code Exchange
4D Resources
Sviluppo4D.it (Italy)
4D Sources (4D Plugin API, 4D Pop & Miyako
Archives
News
Last seven days
Last 30 days
Daily Tips
Last seven days
Last 30 days
Spotlights
Last seven days
Last 30 days
Surveys
Last seven days
Last 30 days
4D Summit
4D Summit 2007
4D Summit 2005
4D Summit 2004
4D Summit 2003
4D Summit 2002
Search Archives
Daily Tips Archive
Below is a list of the tech tips in the 4DToday.com archives.
Previous Displaying 1 to 1
out of 1
Next
15 Aug 2017 Pop-up Menu to get a User selected Field permalink 
Submitted by Keith Culotta, Computer Dimensions, Inc.

// ----------------------------------------------------
  // Method: popup_MenuFromTablePtr - all menu levels
  // --- Create a Dynamic popup menu with Related One fields & get user's selection
  // INPUT1: Pointer - table of origination
  // OUTPUT:  Pointer - to a User selected field
  // ----------------------------------------------------
  // --- params passed from this method to itself
  // INPUT2: Pointer - table to build this level's menu for
  // INPUT3: Pointer - array of menuRefs to eventually clear, add this menu to it
  // INPUT4: menuref - attach this level's menu to this higher level menu
  // INPUT5: Pointer - array of Table Pointers to prevent a table loop

  // ----------- Sample Calling Method ----------- //
  //C_POINTER($fieldPtr)
  //$fieldPtr:=popup_MenuFromTablePtr (->[Table_2])
  //If (Not(Nil($fieldPtr)))
  //ALERT(Field name($fieldPtr))
  //End if
  // ----------- Sample Calling Method ----------- //



C_POINTER($0;$tableOrigPtr;$1;$tableWorkPtr;$2;$3;$aMenuPtr)
C_LONGINT($tableNum;$oneF;$oneT)
C_TEXT($passedMenu;$4;$newMenu;$fieldName)

If (Count parameters>0)

$tableOrigPtr:=$1
If (Count parameters=1)
ARRAY LONGINT($aTableNum;0)
$aTableNumPtr:=(->$aTableNum)
$tableWorkPtr:=$1
$tableNum:=Table($tableWorkPtr)
ARRAY TEXT($aMenus;0)
$aMenuPtr:=(->$aMenus)
$passedMenu:=Create menu
$go:=True
$topLevel:=True
Else
$tableWorkPtr:=$2
$tableNum:=Table($tableWorkPtr)
$aMenuPtr:=$3
$passedMenu:=$4
$aTableNumPtr:=$5
$go:=(Find in array($aTableNumPtr->;$tableNum)=-1)  // - check for circular refs
$topLevel:=False
End if

APPEND TO ARRAY($aMenuPtr->;$passedMenu)

If ($go)
GET FIELD TITLES($tableWorkPtr->;$afT;$afN// omits invisibles
$size:=Size of array($afN)
SORT ARRAY($afT;$afN)

For ($i;1;$size)

GET RELATION PROPERTIES($tableNum;$afN{$i};$oneT;$oneF)
$fieldName:=Field name($tableNum;$afN{$i})

If ($oneT=0)
APPEND MENU ITEM($passedMenu;$fieldName)
SET MENU ITEM PARAMETER($passedMenu;-1;String($tableNum)+" "+String($afN{$i}))

Else
  // in case the relation does not use UUID, it may be useable in the list
GET FIELD PROPERTIES($tableNum;$afN{$i};$fType;$fLength)
If ($fType#0) | ($fLength#0)
APPEND MENU ITEM($passedMenu;$fieldName)
SET MENU ITEM PARAMETER($passedMenu;-1;String($tableNum)+" "+String($afN{$i}))
End if

APPEND TO ARRAY($aTableNumPtr->;Table($tableOrigPtr))

$newMenu:=Create menu
popup_MenuFromTablePtr ($tableOrigPtr;Table($oneT);$aMenuPtr;$newMenu;$aTableNumPtr)
APPEND MENU ITEM($passedMenu;"["+Table name($oneT)+"]";$newMenu)
SET MENU ITEM PARAMETER($passedMenu;-1;String($tableNum)+" "+String($afN{$i}))

End if

End for

If ($topLevel)

$ans:=Dynamic pop up menu ($passedMenu)

For ($i;1;Size of array($aMenus))
RELEASE MENU($aMenus{$i})
End for

If ($ans#"")
ARRAY TEXT($aWords;0)
GET TEXT KEYWORDS($ans;$aWords)
$tn:=Num($aWords{1})
$fn:=Num($aWords{2})
$0:=Field($tn;$fn)
End if

End if

End if

End if