dbTalk Databases Forums  

Script to convert to ASCII nos?

comp.databases.filemaker comp.databases.filemaker


Discuss Script to convert to ASCII nos? in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Emma Grey
 
Posts: n/a

Default Script to convert to ASCII nos? - 05-27-2007 , 10:38 AM






I want to be able to make certain decisions on the basis of the ASCII
numbers of text characters.

If I were working in C this would be simple, but how can I do that in
FileMaker?

To simplify: I'd like to enter an "a" and have a calculation field
convert that to "097", or enter "A" to get "231" etc etc ...

I don't seem to be able to persuade FileMaker to recognise the
difference between "a" and "A". If I convert to ASCII codes, I'll have
much more control.

N.B. Just in case I'm standing on my head for no good reason here, an
example of what I'm trying to to is have FileMaker convert a number of
forenames into initials.

e.g. I'd like to be able to enter "Richard. M." and have a calculation
field make that into "R.M." * using ASCII code seems a good way of
getting FileMaker to keep the Uppercase and ignore the Lowercase.

Thanks to anyone who considers this, and apologies if I've missed
something obvious. I use to be quite skilled at FileMaker a decade ago,
but in recent versions it's become almost a new application.

Emma

Reply With Quote
  #2  
Old   
Ursus
 
Posts: n/a

Default Re: Script to convert to ASCII nos? - 05-27-2007 , 04:47 PM







"Emma Grey" <gone (AT) way (DOT) far> schreef in bericht
news:280520070138350252%gone (AT) way (DOT) far...
Quote:
I want to be able to make certain decisions on the basis of the ASCII
numbers of text characters.

If I were working in C this would be simple, but how can I do that in
FileMaker?

To simplify: I'd like to enter an "a" and have a calculation field
convert that to "097", or enter "A" to get "231" etc etc ...

I don't seem to be able to persuade FileMaker to recognise the
difference between "a" and "A". If I convert to ASCII codes, I'll have
much more control.

N.B. Just in case I'm standing on my head for no good reason here, an
example of what I'm trying to to is have FileMaker convert a number of
forenames into initials.

e.g. I'd like to be able to enter "Richard. M." and have a calculation
field make that into "R.M." * using ASCII code seems a good way of
getting FileMaker to keep the Uppercase and ignore the Lowercase.

Thanks to anyone who considers this, and apologies if I've missed
something obvious. I use to be quite skilled at FileMaker a decade ago,
but in recent versions it's become almost a new application.

Emma
With fmp8 adv you can create custom functions (you didn't state version).
Something like (which i found on Brian Dunnings website, which has a lot of
custom functions)

ASCII <char>
Let(
ASCII = " !"#$%&'()*+,-./0123456789:;ó?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~?ÇüéâäàåçêëèïîìÄÅ ÉæÆôöòûùÿÖÜ¢£¥?fáíóúñѪº"

;

Case( Position ( ASCII ; char ; 1 ; 1 );
// if char exists in ASCII table
Case( PatternCount ( ASCII ; char ) = 2;
// if char appears twice in ASCII table (upper & lower case)
Case( Exact( Middle(ASCII; Position ( ASCII ; char ; 1 ; 1 );
1); char); // if char matches first occurrence
Position ( ASCII ; char ; 1 ; 1 ) + 31;
// convert first occurrence to ASCII code
Position ( ASCII ; char ; 1 ; 2 ) + 31
// convert second occurrence to ASCII code
);
Position ( ASCII ; char ; 1 ; 1 ) + 31
// convert to ASCII code (if char appears once in ASCII table)
);
"")
)

Or simply use the upper/lower functions
If ( exact ( text ) ; upper (text) ) you have an uppercase character.

or look for the amazing UniversalCapitalizer by David Kachel on
http://www.foundationdbs.com/downloads.html

Keep well Ursus




Reply With Quote
  #3  
Old   
Sargasso
 
Posts: n/a

Default Re: Script to convert to ASCII nos? - 05-27-2007 , 09:21 PM



Emma Grey <gone (AT) way (DOT) far> wrote:
Quote:
I want to be able to make certain decisions on the basis of the ASCII
numbers of text characters.

If I were working in C this would be simple, but how can I do that in
FileMaker?

To simplify: I'd like to enter an "a" and have a calculation field
convert that to "097", or enter "A" to get "231" etc etc ...

I don't seem to be able to persuade FileMaker to recognise the
difference between "a" and "A". If I convert to ASCII codes, I'll have
much more control.

N.B. Just in case I'm standing on my head for no good reason here, an
example of what I'm trying to to is have FileMaker convert a number of
forenames into initials.

e.g. I'd like to be able to enter "Richard. M." and have a calculation
field make that into "R.M." * using ASCII code seems a good way of
getting FileMaker to keep the Uppercase and ignore the Lowercase.

Thanks to anyone who considers this, and apologies if I've missed
something obvious. I use to be quite skilled at FileMaker a decade ago,
but in recent versions it's become almost a new application.

Emma
This recursive function might help you on your way ...

NameToInitials ( text )

Let ( wc = WordCount ( text ) ; Case ( wc ; Left ( LeftWords ( text ; 1 ) ; 1 )
& "." & NameToInitials ( RightWords ( text ; wc - 1 ) ) ) )

good luck!



Reply With Quote
  #4  
Old   
Emma Grey
 
Posts: n/a

Default Re: Script to convert to ASCII nos? - 05-28-2007 , 09:46 AM





Thanks to Ursus and Sargasso for your suggestions. I'll be trying them
out ASAP.

Emma

Reply With Quote
  #5  
Old   
Emma Grey
 
Posts: n/a

Default Re: Script to convert to ASCII nos? - 05-28-2007 , 09:48 AM



In article <4659fc62$0$99475$dbd4f001 (AT) news (DOT) wanadoo.nl>, Ursus
<ursus.kirk (AT) wanadoo (DOT) nl> wrote:

Thanks Ursus, I'm using 8.0v1.

Emma

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.