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.

Anyone who speaks php ?

Featured Replies

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 !

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

  • Author

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

-R2D2-

  • Author

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

Thank you again !

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.