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

I do NOT know what to do with this

Featured Replies

I have to validate some field entries and I was given the calculationcode by my boss. He got it from the account we're working for. Anyway, the problem is, its a PHP validation. The guy that made the calc said that it is possible to create the same one in FM too - but I don't even know where to start. The code is:

$number % 9 == 9 - (ord($letter) -54) %9

What the user NEEDS to enter is a 12 digit serialnumber and the first character is a LETTER ((ex: P123456789123). the ORD function replaces the letter with a number (ex. a=1, B=2, c-3 ... z=26). $number are the 11 numbers (without the letter)...

Sorry if this is confusing or even an unwanted post since its about PHP too, but I 'm stuck on this thing...

JP

Ps. Bob Weaver did a great thing for me with the other request about the letter and numbers, but I didn't know then that I had to validate it like this.

  • Newbies

Hi,

I do a validation for a case like this, which uses

Length(FieldName) = 12 and Length(TextToNum(FieldName)) = 11 and TextToNum(FieldName) = Right(FieldName, 11)

It works. But I'm afraid I can't help you with the php... crazy.gif

  • Author

Thx EFmorph

I did have the right calc for the letter+number part, but still thanks.

About the PHP: Seems that '%' is a modulo-operator in PHP so I redid the code in fmp to the following:

Mod(NumberSerie; 9) = Mod(9 -(ValueLetter-54);9)-1

In short what is does is valdiate serialnumbers, where the MOD of the NUMBERS is equal to the MOD of the LETTER, when the letter is transformed into ASCII. If the outcome of both MODs are the same the serial is valid.

A new question arises cause I do not know how to covert letters to ascii in a calculation. I have a few letters ATM so thats easily done, but I'm not planning on doing 54 letters (upper/lowercase) in a [Case] string. If anyone knows how to convert those on the fly in a calc I would really apreciate it.

Thank for thinking with me smile.gif

JP

If I understand correctly, what you want is exactly like the validation from your earlier post except that it's now one letter plus 11 digits instead of one letter plus 6 digits. If so, and if you are still doing this within Filemaker (as a field validation calc) then the formula that I posted before could be changed to:

Length(SerNoField) = 12 and Position("ABCDEFGHIJKLMNOPQRSTUVWXYZ", Left(SerNoField, 1), 1, 1) and (TextToNum("1" & Middle(SerNoField, 2, 11))>100000000000)

This may not perform in precisely the same way as the PHP formula, but it accomplishes the same thing.

There are no Filemaker functions to directly convert characters into their ASCII codes. You can cobble one together using the Position() function, but it won't do you a lot of good, since you can't do much with the codes in Filemaker once you get them.

  • Author

Thanks again Bob,

I tried to do the ascii thing in FM but you are right on that - won't do me any good. What I did now was create a case where I manually entered 26 values (only uppercase needed), and included the right side of the original (PHP-) calc. So that calcfield will give me the right outcome based on the serialletter entered (using your code).

The left side (also based on your calc) does the MOD-calc on the numbers.

The only thing thats bugging me a little is the fact that I had to put a trailing '-1' on the calc [ Mod(NumberSerie; 9) = Mod(9 -(ValueLetter-54);9)-1 ] , I need to put it there but I can't figure out why.

Not a big prob, 'cause the calc is working perfectly, it's just bugging me smile.gif

Thanks for all your help

I would use the following:

(Mod(serial, 9) = 9 -Mod(64+Position("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Left(serial, 1), 1, 1) -54,9)) and

Length("1" & TextToNum(serial)) = Length(serial) and

Length(serial)=12

Dj

Okay, it looks like the last digit in the serial number is actually a kind of checksum. I didn't notice that before.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.