Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

DQ_New ( initialContents )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.5  (26 votes)
  Discuss this Custom Function

Stephen Hanna, Stephen J. Hanna Consulting
http://www.sjhanna.com

Creates a double-ended queue (DeQue)

Sample Input:
DQ_New( List( "apple" ; "pear" ) )
Sample Output:
$$__DQ000001


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

This is a "constructor" function for a package that implements a double-ended queue (DeQue, sometimes pronounced "deck"). DeQues can be used to implement Stacks (LIFO), Queues (FIFO), or more general data structures. Five operations are defined on DeQues: Push and Pop, which add and remove items from the front (top) of the DeQue (thus causing it to behave like a stack); Put and Pull, which add and remove items from the end (bottom) of the DeQue (so Push and Pull are the basic FIFO queue operators); and Count, which returns the number of items in the DeQue.

These functions implement DeQues as global variables, but you don't need to know this or the names of the created variables. DQ_New returns the name of the variable it creates, and all the other manipulation functions accept this name as their first (or only) parameter. Thus, a typical usage sequence would be:

Set Variable [ "$myStack" ; DQ_New ( "apple" ) ) ]
Set Variable [ "$dummy" ; DQ_Push ( $myStack ; "banana" ) ]
Set Variable [ "$dummy" ; DQ_Put ( $myStack ; "cherry" ) ]
Set Variable [ "$myCount" ; DQ_Count ( $myStack ) ] // $myCount = 3
Set Variable [ "$fruit" ; DQ_Pull ( $myStack ) ] // $fruit = "cherry"
Set Variable [ "$fruit" ; DQ_Pop ( $myStack ) ] // $fruit = "banana"
Set Variable [ "$myCount" ; DQ_Count ( $myStack ) ] // $myCount = 1

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

Not one of your function definitions is is valid.

For instance you describe a function DQ_New ( initialContents )

But in fact the function definition does not contain a parameter "initialContents"

Bruce Robertson, Redmond WA
March 28, 2013 9:55pm

All of the functions are valid (at least to FileMaker), although I grant that there is a discrepancy between the names I used for the parameters in the description and the names used in the functions themselves. The parameter names used in the function are arbitrary, as long as they conform to FileMaker variable-naming rules. However, I have changed the name of the parameter in DQ_New() to match the description.

Stephen Hanna, Cupertino
March 28, 2013 11:26pm

You should do the same thing (correct the param names) for the other functions.

I also note that trying to use the data viewer to experiment with any of these functions results in a rapid accumulation of new instances of global variables.

Bruce Robertson, Redmond WA
March 29, 2013 12:46am

On the comment about global variables: Yes, that's true, because that's how the routines store the data structures. In normal use, you'd create one new structure, and hence one global variable, for each data structure you want to use. You'd then use the other functions (Push and Pop if you want to treat it as a stack, Push and Pull if you want a queue) to manipulate those structures. The idea is that you don't have to know what variables are being created behind the scenes -- just store the name that DQ_New returns to you in your own variable (or field), and pass that to the subsequent routines. [Note, by the way, that there are a total of six routines, only four of which have been posted so far: Pop and Pull are still awaiting approval.]

Stephen Hanna, Cupertino
March 29, 2013 2:10am

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 3 + 4 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. ProperAllWords ( text )
  (Thu, Dec 14, 5:19pm)
2. MatchExist ( SourceTable.Field ; DestTable.Field ; ReturnField )
  (Thu, Dec 14, 1:07pm)
3. BVR_Format ( bvr )
  (Wed, Dec 13, 5:32pm)
4. NumberToHexadecimal(NumberValue)
  (Fri, Dec 08, 8:54am)
5. Get_BaseTable
  (Thu, Dec 07, 4:27pm)
6. JSONCreateVarsFromKeys ( json ; namespace )
  (Wed, Dec 06, 8:21pm)
7. GetTableNzme ( field )
  (Tue, Dec 05, 9:16pm)
8. TimeFormatAsText ( theTime )
  (Mon, Nov 13, 1:59pm)

RSS Feed of Custom Functions