Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Translation needed...

I need to make a calculation field to produce a bank transfer reference check number. It is to last number added to the reference string. I have a php calculation for this, but I do not "speak" php, so could someone be so kind to translate this to FM calculation format...

php:

$number1=$_GET('number');

$ref=CalculateRef($number1);

echo $ref;

function CalculateRef ($number) (

$multiplier="7137137137137137137"

if (CheckNumber ($number)) (

$length=strlen(strval($number) );

$apui=strlen(strval($multiplier) );

for ($i=$length; $i>0 ; $i--) (

$result=$result+($number[$i]*$multiplier[$apui]);

$apui--;

}

$check = (10- ($result % 10)) %10;

$ref=$number.$check;

return $ref;

} else {

echo "input the number to be calculated"

}

}

function CheckNumber ($NumberToCheck) {

if ( is_numeric($NumberToCheck) ) {

$length=strlen(strval($NumberToCheck) );

if ($length>2 && $length<20) {

return True;

} else {

echo "Your number is too short or long. Should be between 3-19 numbers";

return False

}

} else {

return False;

}

}

?>

There is a lot I understand, but the calculation formula is a big question mark for me how to import it to FM calculation. I have translated the variables to english for easier you to understand. I hope they are some what correct...

Big thanks in advance !

Posted (edited)

Due to the recursion requirement, you'll have to add a CF into the mix, but something like the following should do just fine (I realize multiplify is not a word.

Main Call


Let([

num = yourNumberHere;

multiplier = 7137137137137137137;

leng = if( Length(Filter(num;"0123456789")) = Length(num) ; Length(num); -1 );

apui = Length(multiplier);

result = MultiplifyNumber(num;multiplier;leng;apui)

];

	Case( leng = -1 ; "Please input a numeric string only" ;

	leng > 2 AND leng < 20 ; num & Mod(10 - Mod(result;10);10);

	"Your num is too short or long. Shuold be between 3-19 nums" )

)





Custom Function

MultiplifyNumber(num;multiplier;leng;apui)



Middle(num;leng;1)*Middle(multiplier;apui;1) + If( leng > 1 ; MultiplifyNumber(num;multiplier;leng-1;apui-1) )

Edited by Guest
Posted

Thanks a lot, Genx ! I owe you one. I'll try that when I get home.

-R2D2-

Posted

Yes ! It really calculates the reference number correctly. Checked with real invoices.

Thank you again !

This topic is 5761 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.