DPaquin Posted September 25, 2019 Posted September 25, 2019 (edited) 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 September 25, 2019 by DPaquin
comment Posted September 25, 2019 Posted September 25, 2019 (edited) 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 September 25, 2019 by comment
DPaquin Posted September 25, 2019 Author Posted September 25, 2019 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!"
comment Posted September 25, 2019 Posted September 25, 2019 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" ] ) ) 1
DPaquin Posted September 25, 2019 Author Posted September 25, 2019 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
comment Posted September 25, 2019 Posted September 25, 2019 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).
Steve Martino Posted September 25, 2019 Posted September 25, 2019 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.
comment Posted September 25, 2019 Posted September 25, 2019 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.
Recommended Posts
This topic is 1954 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now