Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5377 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

FileMaker gives us local and global variables, which are quite useful. Further, these variables can have a "repetition number" in square bracket format such as $data[23] or $data[0] or $data[-128]. The repetition can be "sparse" - you can set rep #1 and 17 and 85 without setting any other rep numbers.

As it turns out, these integer values can be large. As in quite large; as in integers of over 400 digits.

Well - OK - but what good is that???

Let us consider another FileMaker feature. We now have the code() and char() functions. Code( "a") produces result 97.

Code( "FMForums") produces:

11500109001170011400111000700007700070

And it is reversible:

Char( 11500109001170011400111000700007700070 )

produces

FMForums

This reversibility works for a string length up to 80 characters (resulting integer is 397 digits )

This allows us to create "named buckets" which we can set and get and update.

Set variable $msg [ code( "Bruce technique #1")] = "some chunk of text"

See attached file for a crosstab technique which uses named buckets to give an "address" for each row/column intersection.

cfreporting.zip

Edited by Guest
Posted

You can also do things like use spreadsheet nomenclature:

Let( $$data[code("R1C12")] = "Cool things to do with variawobbles";"")

$$data[code("R1C12")]

Cool things to do with variawobbles

Posted (edited)

Excellent tip :)

Just FYI Code ( ) only evaluates to 80 characters anything longer you get a question mark.

Edited by Guest
Posted (edited)

Excellent tip :)

Just FYI Code ( ) only evaluates to 80 characters anything longer you get a question mark.

Thanks! I did mention the 80 character limit for code(), but you've provide a little more detail. Note that this limit does not apply to the size of the rep integer - it looks like that can be up to 800 digits!

Edited by Guest
Posted

Max length of digit string undetermined at this point. I have tested lengths up to 100,000 digits and $$var[100k digits] still sets/gets a valid result and no error. If non-digits are in the string it becomes $$var[0].

Posted

Let me see if I understand what you are doing.

A substitution cypher in which you translate the text into a unique id and make that a repetition number?

So instead of set variable by calculation you are setting the variable repetition?

Oreste

Posted (edited)

Let me see if I understand what you are doing.

A substitution cypher in which you translate the text into a unique id and make that a repetition number?

So instead of set variable by calculation you are setting the variable repetition?

Oreste

I don't really understand what you're saying; but you may be correct.

I don't know what you mean by setting the variable by calculation.

I guess you could call it a unique ID. The code() function is a standard FileMaker function. It is an operation that converts text into a digit string that represents the 5 digit unicode value of each character. The last (rightmost) 5 digits of the result represents the first character of the original text; etc.

We can't get/set/update $data["Bruce"] but we can do $data[code("Bruce")]. Yes we are setting the repetition.

So imagine we have product ID "X123".

We can get data from a record set and do things like:

Loop

Let([

partnum = Invoice_Items::ProductID;

partnum_code = code( partNum);

$qty_sold[ partnum_code ]= $qty_sold[partnum_code] + Invoice_Items::Qty_ordered;

$order_ID_list[ partnum_code ] = List($order_ID_list[ partnum_code ] ; Invoice_Items::fk_OrderID );

$cust_ID_List[ partnum_code ] = List( $cust_ID_List[ partnum_code ] ; Orders::CustomerID);

$partnum_List = case( isEmpty( filterValues( partNum; $partNum_List )); List( $partNum_list; partnum); $partNum_list) ];

"" )

Go next exit after last

End Loop

Now we can do:

$cust_ID_List[ code("X123")] and find out who ordered the part.

Etc.

Edited by Guest
Posted

I just created a custom function to use this for setting CodeNamedVariables for setting and getting the values.

CNV ( name ; value ; execute )

E// the namespace for this variable is $$_cnv for Code Named Variable

Case (

// SET THE VARIABLE

execute = 0 ;

Evaluate ( "Let ( $$_cnv[Code (""& name &"")] = "" & value & "" ; "" ) " ) ;

// GET THE VARIABLE KEEPING STORED ;

execute = 1 ;

Evaluate ( "$$_cnv[ Code ("" & name & "")]" ) ;

// GET VARIABLE DESTROY

execute = 2;

Evaluate ( "$$_cnv[ Code ("" & name & "")]" ) & Evaluate ( "Let ( $$_cnv[Code (""& name &"")] = "" ; "" ) " );

// DESTROY VARIABLE

execute = 3;

Evaluate ( "Let ( $$_cnv[Code (""& name &"")] = "" ; "" ) " )

)

So i could assign variables in the parameters on a button CNV ( "FirstName" ; firstNameField ; 0 ) & CNV ( "LastName" ; LastNameField ; 0 )

and to pull the value you'd use CNV ( "FirstName" ; 0 ; 1 ) would result in the value stored in the variable.

if you used CNV ( "FirstName" ; 0 ; 2 ) you would get the value of the variable and then destroy the variable.

CNV ( "FirstName ; 0 ; 3 ) would destroy the variable

Just a thought :)

Posted (edited)

Nice!

Maybe add one more thing - a way to list all the variables created, maybe variable $$CNV_List.

Something else bizarre to ponder is that this method allows passing return delimited lists. Actually ANY text.

You could have CNV( "First¶Last¶Address¶City¶State¶Zip"; List(thosefields); 0 )

Edited by Guest
Posted

LOL, i was just thinking that myself making the very first value $$_cnv[] a list of all the items contained within.

The only problem in using a List ( ) function is that if there are any blank fields it doesn't preserve the empty row so the name / value would not line up.

Either add this to the function or make it a another function that would set the current values

in the a global variable like this:

variable = value

variable = value

as this method looking the data viewer you can comprehend as the code method is somewhat not easy to decipher.

Posted

Yup, indecipherable in the data viewer and you can't get a list of declared integers unless you make it yourself. This is one reason I think it may have more applicability with local variables, they destroy themselves after the script runs and you don't have to track them.

Posted

Hi, The set variable script step does not allow me to see via calculation. I need to hard code that. So lets say I have a field called variable, and another called value. I want to have a user type in "Test" to the variable field and "Hammer" to the value field. I run a script that sets $$test to Hammer. I cant do this in FM, unless I use a Custom Function. With your method I can create a Unique id and then set the value. So I have a script that says set variable $$something [code(test)] to Hammer.

What is the reason to use this method. What problem does it solve?

Posted

Problem solved? It CAN be done - should we do it? When should we do it? Good question and I expect we will be exploring it for a while. What are the differences?

One problem it solves is variable names; they can be ANYTHING. You cannot create a variable name "$pid X74 Q1 2010" - the spaces would be a problem.

It may also be faster than evaluate() methods used to generate variables that you describe.

Yes, reading the resulting variable rep number is essentially impossible. But reading the script is really really easy as shown in my examples further up. None of that messy backslash quoting stuff.

Because the rep num can encode ANYTHING then it is very easy to find data matches for any kind of data you want to work with.

I really like the ability to use base variable names and get their variations: $sales[ coded_productID ] is very easy to understand.

In my FileMaker SIG group I have a fellow involved in genetics. It will be very easy to do pattern matching on very large data this way. I don't know if you can create a variable name that is 100K digits long; but you can create a rep number that is 100K digits.

One application I came up with today was finding all fields on a layout that are stacked on top of each other. This was to support a technique I'm testing where there is only one real data entry field on a layout. It is a global field - the same global field - under every "editable" displayed field. I can find which field the user clicks into and use a trigger to go to the global underneath it. I do this by encoding the bounds of all the fields; then you can find objects that match.

Posted

"I run a script that sets $$test to Hammer. I cant do this in FM, unless I use a Custom Function."

Well, I don't think that's true.

Posted (edited)

I believe it's 800 digits at most.

Why do you believe that?

Did you test? I have. That's why I made the statement.

> 100K digits DOES work.

Edited by Guest
Posted

It does work - or rather seems to be working - but the actual repetition being set is repetition ?. Open up your Data Viewer and look at the "Current" tab.

Posted (edited)

OK, oops, did some further testing, you're right. The variable appeared to be set but no new variables were being created. So yes, the limit is 800 digits.

Edited by Guest
Posted

I am afraid you are missing the point. Set $variable[n] to "alpha" and $variable[m] to "beta", with n and m being "numbers" with more than 800 digits. Now try to retrieve $variable[n].

Posted (edited)

I am afraid you are missing the point. Set $variable[n] to "alpha" and $variable[m] to "beta", with n and m being "numbers" with more than 800 digits. Now try to retrieve $variable[n].

I had been setting and getting a single N for $var[N] and DID get the value. But youze correct.

Note: N can be positive or negative number with 800 or less digits.

Edited by Guest
Posted

I had been setting and getting a single N for $var[N] and DID get the value.

Of course you did, because it wasn't overwritten. You could also retrieve the same by:

$variable[$e]

where $e = 1/0.

BTW, all of this is rather old stuff:

http://fmforums.com/forum/showtopic.php?tid/187553/post/254240/#254241

Note that even the ±800 digits range remains unproven.

Posted (edited)

OK yes, many of the questions came up in that thread but now we have easy encoding decoding with Code() and Char() that came with 10.

How is it that you figure ±800 is not proven?

Watch data viewer with attached.

RepCodeTest.fp7.zip

Edited by Guest
Posted (edited)

Saw that, not buying it. Why not just doubt every calculation FileMaker performs? In my file just posted you can see the creation of new variables happening for length N <=800. You can also see - as you note - that once the 800 length is exceeded no new variables are created but the variable of $data[?] changes.

Attached file demonstrates (I think) your N-M comparison result.

RepCodeTest.fp7.zip

Edited by Guest
Posted

I don't recall trying to sell anything - I was merely stating a fact (or rather the lack thereof). What you choose to believe is entirely at your discretion and no concern of mine.

Why not just doubt every calculation FileMaker performs?

Why not indeed? There are plenty of examples where such doubt has been justified.

  • Like 1
Posted

Well, I'd like to just move on to practical applications of the technique, some of which were addressed in the previously mentioned thread.

Data can be put into variable names either by naming the basic variable or by the rep name method. For products::ProductID of X123, either $Sales_X123 or $sales[code("X123")].

Since we do not have a function ListVariableNames, then in either case we may need to accumulate a list of assigned variable names as they are built, if we want to walk the list at some point.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.