Jump to content

Error with custom function


DPaquin

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

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

 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

Link to comment
Share on other sites

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" ]
)
)

 

  • Like 1
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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).

 

Link to comment
Share on other sites

This topic is 1646 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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