4DToday.com
Home Directory Classifieds Reference Archives
Site Info
About 4DToday.com
Contact Us
Version française
Quote
Developers (721)
4D Developers (589)
Web Developers (334)
Tools Publishers (192)
Instructors (164)
Web Hosts (60)
Resellers (87)
Software Publishers (297)
Search Developers
Products (384)
Plug-Ins (111)
Components (48)
Code Libraries (9)
Books (7)
Tools (42)
Vertical Applications (146)
Search Products
User Groups
All User Groups (22)
Classified Ads (21)
Help Wanted (6)
Opportunities Wanted (12)
Hardware Wanted (0)
Hardware for Sale (0)
Software Wanted (1)
Software for Sale (0)
Other (0)
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
Quote
I live in that solitude which is painful in youth, but delicious in the years of maturity.
Albert Einstein  
  Suggest a Quote  
Developer News
There are no news items at this time.
 Submit Future News    Archive 
Technical Tip
Pop-up Menu to get a User selected Field
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
  Submit a Tip    Archive 
Spotlight
Active4D 64-bit
Active4D 64-bit Active4D is now available for 4D v12 64-bit Server! Take full advantage of your 64-bit hardware with the power of Active4D.
  Suggest a Spotlight  
Survey Question
Today, we ask you...
Still working on survey, please vote for debugging purposes...
What is your basic, average hourly rate for 4D consulting? (In US Dollars)
$0 - $50
$51 - $75
$76 - $100
$101 - $150
$151 - $200
$201 - up

Survey submitted by Tim Nevels
  Show Results (no vote)    Suggest a Survey  
Events
There are no events scheduled for the upcoming fortnight.
  Submit an Event