number, letter, upper or lower?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
CodeLobster

number, letter, upper or lower?

Post by CodeLobster »

im trying to find this but it seems that i have no such option.

i need to test if a string is a number or a letter, lower or upper case for the latter.

scripted solution is painfully slow, even with an optimzed code thats probability-aware.

any ideas please?

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: number, letter, upper or lower?

Post by Stefan »

CodeLobster wrote:im trying to find this but it seems that i have no such option.

i need to test if a string is a number or a letter, lower or upper case for the latter.

scripted solution is painfully slow, even with an optimzed code thats probability-aware.

any ideas please?
See asc() command and google for ascii table.

CodeLobster

Re: number, letter, upper or lower?

Post by CodeLobster »

Stefan wrote:
CodeLobster wrote:im trying to find this but it seems that i have no such option.

i need to test if a string is a number or a letter, lower or upper case for the latter.

scripted solution is painfully slow, even with an optimzed code thats probability-aware.

any ideas please?
See asc() command and google for ascii table.
wouldnt it be the same as declaring each letter or number on a table?

as i can foresee this would be even slower than what i already do which is listing chars

on tables for char-by-char comparison.

diacritic'ed letters fall into the not a number nor a letter category unless i

list them on respective tables by the way.

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: number, letter, upper or lower?

Post by Stefan »

diacritic letters have an number too, but you didn't find them on an ascci table.


Code: Select all

msg asc("â");  msg asc("è");

  $i=200; $arr="";  while($i < 240){ $arr = $arr . chr($i) . "<crlf>"; $i++;} text $arr;

I would do what you want like this:

Code: Select all

 //48=0, 49=1, 50=2,... 57=9
  $token = "3";
  $asc = asc($token); msg $asc;
  if ( $asc > 47 && $asc < 58){ msg "it is an digit";}else{ msg "not an digit";}

  //51
  //"it is an digit"



  $token = "x";
  $asc = asc($token); msg $asc;
  if ( $asc > 47 && $asc < 58){ msg "it is an digit";}else{ msg "not an digit";}

  //120
  //"not an digit"

CodeLobster

Re: number, letter, upper or lower?

Post by CodeLobster »

would you mind in elaborating your test over diacritics a bit more, stefan?

it seems it will scan systems codepage am i right?

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: number, letter, upper or lower?

Post by Stefan »

CodeLobster wrote:would you mind in elaborating your test over diacritics a bit more, stefan?

it seems it will scan systems codepage am i right?
Your system use an codepage to translate keyboard scancodes (for an key) to an glyph,
in the paste there was only 7 bit codepage = 128 signs (ASCII), then there was an extended 8-bit table (256 signs) (extended ascii)
now there are unicode codepage which can hold thousands of different items.
But the base, the first 128 signs are still the same as the old standard ascii table.

The decimal code 48 till 57 stands for digits 0 till 9 (48=0, 49=1, 50=2,... 57=9)
65 till 90 are A-Z
97 till 122 are a-z

What else digits are from interest for you depends on your used codepage.

See your start menu > programs > accessories > system apps > code table (or smtg like that)

Or use this code to see the mapping digit<>glyph

Code: Select all

  $i=33; $arr="";
  while($i < 1640){ $arr = $arr . "$i=" . chr($i) . "<crlf>"; $i++;} text $arr;
The max number depends on your used codepage. I guess asians use higher number then european.

Now you can check which signs are from interest for you and use an code to check the asc() of each token of an string to see if it is an digit, an char or an sign.

Wasn't there an command to change diacritics to standard english chars, which could be used firstly?

CodeLobster

Re: number, letter, upper or lower?

Post by CodeLobster »

Stefan wrote: Wasn't there an command to change diacritics to standard english chars, which could be used firstly?
if you refer to recase, remove diacritics i have to check whether or not it returns operation successful.

all in all your post was very appreciated and it turned out to be a quicker mean to perform some verifications, have to check now the diacritics, punctuation marks. thank u.

Post Reply