Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hello,

I am not to knowledgeable with custom function. I’m having difficulties, I am getting an error.

I’m investigating the input « dataIN » and returning the result in « dataIN »

Case (

 

Parameter = “deCRYPT” (substitute( $dataIN ;

[“b”;”0”];[“c”;”1”];[“d”;”2”];[“e”;”3”];[“f”;”4”];[“g”;”5”];[“h”;”6”];[“I”;”7”];[“j”;”8”];[“k”;”9”];

["m";"0"];["n";"1"];["o";"2"];["p";"3"];["q";"4"];["r";"5"];["s";"6"];["t";"7"];["u";"8"];["v";"9"];

["B";"0"];["C";"1"];["D";"2"];["E";"3"];["F";"4"];["G";"5"];["H";"6"];["I";"7"];["J";"8"];["K";"9"];

["M";"0"];["N";"1"];["O";"2"];["P";"3"];["Q";"4"];["R";"5"];["S";"6"];["T";"7"];["U";"8"];["V";"9"]  );

 

Parameter = “cryptA” (substitute( $dataIN ;

[“0”;”b”];[“1”;”c”];[“2”;”d”];[“3”;”e”];[“4”;”f”];[“5”;”g”];[“6”;”h”];[“7”;”I”];[“8”;”j”];[“9”;”k”]);

 

Parameter = “cryptL” (substitute( $dataIN ;

[“0”;”m”];[“1”;”n”];[“2”;”o”];[“3”;”p”];[“4”;”q”];[“5”;”r”];[“6”;”s”];[“7”;”t”];[“8”;”u”];[“9”;”v”] )

)

Edited by DPaquin

It's hard to advise when we don't know what you're trying to accomplish. As it is, all I can say that what you posted has syntax errors. Perhaps you meant:

Case (

Parameter = "deCRYPT" ; Substitute( $dataIN ;
["b";"0"];["c";"1"];["d";"2"];["e";"3"];["f";"4"];["g";"5"];["h";"6"];["I";"7"];["j";"8"];["k";"9"];
["m";"0"];["n";"1"];["o";"2"];["p";"3"];["q";"4"];["r";"5"];["s";"6"];["t";"7"];["u";"8"];["v";"9"];
["B";"0"];["C";"1"];["D";"2"];["E";"3"];["F";"4"];["G";"5"];["H";"6"];["I";"7"];["J";"8"];["K";"9"];
["M";"0"];["N";"1"];["O";"2"];["P";"3"];["Q";"4"];["R";"5"];["S";"6"];["T";"7"];["U";"8"];["V";"9"] ) ;
 
Parameter = "cryptA" ; Substitute( $dataIN ;
["0";"b"];["1";"c"];["2";"d"];["3";"e"];["4";"f"];["5";"g"];["6";"h"];["7";"I"];["8";"j"];["9";"k"]);

Parameter = "cryptL" ; Substitute( $dataIN ;
["0";"m"];["1";"n"];["2";"o"];["3";"p"];["4";"q"];["5";"r"];["6";"s"];["7";"t"];["8";"u"];["9";"v"] )

)

I am not sure how and where you intend to use this. Speaking in general, a custom function should process its own parameters and not depend on a $variable.

--
P.S. Next time, when you get an error, post the error message.

 

Edited by comment

  • Author

 Thanks for your help.

Sorry for providing more information. 

What I am trying to do is to convert letters to numbers or numbers (encrypting) to letters (crypting) based on the attached table. This is very very basic crypting. 

When "Parameter" is equal to "deCRYPT" the dataIN could be equal to something like:

"edbbc" expected result is 32001

"pomp" expected result is 32001

 

When Parameter is equal to "cryptA" and dataIN is equal to 12113 the expected result would be "cdcce"

When Parameter is equal to "cryptL" and dataIN is equal to 12113 the expected result would be "nonnp

 

Many thanks!"

 

Screen Shot 2019-09-25 at 11.38.18 AM.png

Screen Shot 2019-09-25 at 11.40.44 AM.png

Screen Shot 2019-09-25 at 11.40.55 AM.png

I think the code above should work for you, then - you only need to change $dataIN to dataIN.

You could make this a bit more elegant, though - say:

wDECRYPT ( input ; action ) =

Case (
action = "decrypt" ; Substitute ( Lower ( input ) ;
[ "b" ; "0" ] ; [ "c" ; "1" ] ; [ "d" ; "2" ] ; [ "e" ; "3" ] ; [ "f" ; "4" ] ; [ "g" ; "5" ] ; [ "h" ; "6" ] ; [ "I" ; "7" ] ; [ "j" ; "8" ] ; [ "k" ; "9" ] ;
[ "m" ; "0" ] ; [ "n" ; "1" ] ; [ "o" ; "2" ] ; [ "p" ; "3" ] ; [ "q" ; "4" ] ; [ "r" ; "5" ] ; [ "s" ; "6" ] ; [ "t" ; "7" ] ; [ "u" ; "8" ] ; [ "v" ; "9" ]
) ;
action = "cryptA" ; Substitute ( input ;
[ "0" ; "b" ] ; [ "1" ; "c" ] ; [ "2" ; "d" ] ; [ "3" ; "e" ] ; [ "4" ; "f" ] ; [ "5" ; "g" ] ; [ "6" ; "h" ] ; [ "7" ; "I" ] ; [ "8" ; "j" ] ; [ "9" ; "k" ]
);
action = "cryptL" ; Substitute ( input ;
[ "0" ; "m" ] ; [ "1" ; "n" ] ; [ "2" ; "o" ] ; [ "3" ; "p" ] ; [ "4" ; "q" ] ; [ "5" ; "r" ] ; [ "6" ; "s" ] ; [ "7" ; "t" ] ; [ "8" ; "u" ] ; [ "9" ; "v" ]
)
)

 

  • Author

Many thanks !

 

Is there something I could read which would help me when coding custom functions. I'm subscribing to Lynda.com and did not find anything on this type of programming.

 

When browsing the internet I do find a lot of information about filemaker scripting but not much about coding, scripting custom functions.

 

With regards!

 

Daniel

 

43 minutes ago, DPaquin said:

Is there something I could read

I am afraid I don't know. I suppose there are many resources out there - not the least among them this forum, with its many examples.

Note that this may not be the best example of constructing a custom function. It's actually no more than a simple calculation; the only reason to make it a custom function would be if you have to use it in several places. More often, a custom function would be used for a recursive calculation - something that cannot be done within a calculation field (or rather couldn't be done before version 18).

 

OP, In your post that shows the screenshot with the error message, you were just missing the last ")" to close the Case statement.

But as always, comment has the better way.

23 minutes ago, Steve Martino said:

you were just missing the last ")" to close the Case statement.

There were additional syntax errors - notably an opening parenthesis instead of a semicolon separating the test and the result.

 

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.