Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted (edited)

I was doing a bit of work for a client who is running FM9 clients, connecting to a file hosted on an FM11 server.  I don't have FM9, so was doing development on FM11.  I thought I had checked out that everything was compatible, but I somehow generated a calculation that doesn't evaluate on 9, but does on 11.  The components of the calculations and custom functions used all appear to be innocuous...  I  am hoping someone here knows what I tripped up on.

Here's the field calculation, and the 2 custom function definitions that it uses.  The entire point of this calculation is to take a mish-mash text field that they have and make it sort nicely.  For this bit I added, I'm just concerning myself with sorting some suffix numbers that occur between parentheses, e.g. 12345(A-1).

 

Field calculation definition:

Let ( [
	_fileNum = Files::File Number ;

//Position of 1st open/close parens, and then extract the text between them:
	_sParen = Position ( _fileNum ; "(" ; 1 ; 1 ) + 1;
	_eParen = Position ( _fileNum ; ")" ; 1 ; 1 ) ;
	_suffix = Middle ( _fileNum ; _sParen ; _eParen - _sParen) ;
	
//Count the leading digits before any non-digit character, e.g. an alpha, or dash or space, etc.
	_count = CountPrefixDigits ( _suffix ; 0 ) ;

//Remove extraneous characters (dash, space):
	_suffix =  Substitute ( _suffix; ["-";""]; [" " ; ""] ) ;

//Pad out the string to min 5 characters (helps 75-A sort next to 75):
	_suffix = _suffix & Left ( "!!!!!" ; 5 - Length (_suffix) );

//Reverse the character sequence (so the Code() call works out better):
	_suffix = ReverseString ( _suffix ) 
];

_count & Code ( _suffix )    //prepend the digit count, but don't encode that count, just the rest of it

)


--------------------
'CountPrefixDigits ( aString ; aCounter )' custom function:

If ( 
	IsEmpty ( GetAsNumber ( Left ( aString ; 1 ) ) ) ; 
	aCounter ;
	CountPrefixDigits ( Right ( aString ; Length ( aString) - 1 ) ; aCounter + 1 )
)

--------------------

'ReverseString (aString)' custom function:

If ( 
	Length ( aString ) > 0 ;
	ReverseString ( Right ( aString ; Length ( aString ) - 1 ) ) & Left ( aString ; 1 ) ; 
	Left ( aString ; 1 )
)


 

Thanks,

Justin

 

Edited by Justin Close

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