isNumber

All flavors welcome.
Forum rules
Be kind.
Post Reply
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

isNumber

Post by richmond62 »

"Over there" (which seems right now to be experiencing a denial of service attack (8 April)) someone mentioned isNumber, which, after 32 years of working with xTalk I have NEVER encountered (which may prove how under-somethinged the language is) . . .
-
SShot 2025-04-08 at 12.09.10.png
SShot 2025-04-08 at 12.09.10.png (171.56 KiB) Viewed 2453 times
Attachments
Number Check.oxtstack
(1.21 KiB) Downloaded 95 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

While it is undoubtedly useful to determine where something is a number or an alphabetic form, what also might be useful is to determine whether something is written is some language or not:

'Hello, Happy People' might return 'English', or, at least 'Latin' (as in alphabet), while

'Здрасти, хора' might reutrn 'Bulgarian', or, at least 'Cyrillic'.

But I am not sure whether that could be done without leveraging Unicode ranges.
https://richmondmathewson.owlstown.net/
User avatar
OpenXTalkPaul
Posts: 2836
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: isNumber

Post by OpenXTalkPaul »

richmond62 wrote: Tue Apr 08, 2025 9:12 am after 32 years of working with xTalk I have NEVER encountered
I still find syntax I was unaware of once in a while, I was not aware of this function, but that's probably because I wasn't looking for it, it's functionality is replicated with the expression 'is a', that syntax has more options:

Code: Select all

"1/16/98" is a date -- evaluates to true
1 is a boolean -- evaluates to false
45.4 is an integer -- evaluates to false
"red" is a color -- evaluates to true
local tArray
put "test" into tArray[1] 
put tArray is an array -- evaluates to true
numToChar(128) is an ASCII string -- evaluates to false
This is something I wanted to discuss in the thread evaluating what makes an xTalk qualify as an xTalk, that is data types.
User avatar
tperry2x
Posts: 3522
Joined: Tue Dec 21, 2021 9:10 pm
Location: webtalk.tsites.co.uk
Contact:

Re: isNumber

Post by tperry2x »

I've used isNumber elsewhere in the IDE.
as-seen-in-revmenubar.png
as-seen-in-revmenubar.png (18.46 KiB) Viewed 2380 times
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

OK: I'm going to try and get down and dirty with the Unicode Consortium (well, not with the consortium as such, but withe their byproduct) to determine whether a text contains Latin letters and/or Cyrillic letters (and by extension any alphabetic or abugida syllabic set in the Unicode charts).

To start, let's notice that the Unicode Charts for Latin letters are as follows:
-
LatinRanges.png
LatinRanges.png (51.6 KiB) Viewed 2018 times
-
I will exclude the ranges covered in pink as no-one writes letters to Mum using those symbols. 8-)

These ranges are ; Hex 0040 - 007A / Decimal 64 - 122 (part of the ASCII set)
Hex 00CO - 00FF / Decimal 192 - 255
Hex 0100 - 017F / Decimal 256 - 383
Hex 0180 - 024F / Decimal 384 - 591

Hex 2C60 - 2C7F / Decimal 11360 - 11391
Hex A720 - A7CD / Decimal 42784 - 42957
Hex A7D0 - A7D1 / Decimal 42960 - 42961
Hex A7D3 / Decimal 42963
Hex A7D5 - A7DC / Decimal 42965 - 42972
Hex A7F2 - A7FF / Decimal 42994 - 43007
Hex AB30 - AB69 / Decimal 43824 - 43881
Hex 10780 - 10785 / Decimal 67456 - 67461
Hex 10787 - 107B0 / Decimal 67463 - 67504
Hex 107B2 - 107BA / Decimal 67506 - 67514
Hex 1DF00 - 1DF1E / Decimal 122624 - 122654
Hex 1DF25 - 1DF2A / Decimal 122661 - 122666
Hex 1E00 - 1EFF / Decimal 7680 - 7935

The 3 Unicode sets marked in blue may be treated as one range.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

Here is an extremely simple start (it only checks for the Latin letters contained with the ASCII set):
-
Screenshot 2025-04-09 at 17.02.31.png
Screenshot 2025-04-09 at 17.02.31.png (189.09 KiB) Viewed 1989 times
-
Probably life will be simpler as one "gets all hot and sweaty" with a vast number of Unicode glyph ranges to set up a series of functions.

Code: Select all

on mouseUp
   put empty into fld "f2"
   set the lockScreen to true
   put fld "ff" into FFFF
   repeat until FFFF is empty
      put the first char of FFFF into FX
      if isNumber(FX) then
         --do nix
      else 
         put codePointToNum(FX) into FZ
         put RRANGE(FZ) into FQ
         put ("This contains" && FQ && "script") into fld f2
      end if
      delete the first char of FFFF
   end repeat
   set the lockScreen to false
end mouseUp

function RRANGE FZ
   if FZ > 39 and FZ < 123 then
      return "Latin"
   end if
end RRANGE
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

With ALL the Latin ranges in place one can check texts that contain Latin letters that are NOT contained in the ASCII set:

https://is.wikipedia.org/wiki/Fors%C3%AD%C3%B0a

And while this HTML page may screw up Forsiða in a link, OXT Lite will not! 8-)
-
Screenshot 2025-04-09 at 17.36.38.png
Screenshot 2025-04-09 at 17.36.38.png (209.61 KiB) Viewed 1925 times
-

Code: Select all

on mouseUp
   put empty into fld "f2"
   wait 1 sec
   set the lockScreen to true
   put fld "ff" into FFFF
   repeat until FFFF is empty
      put the first char of FFFF into FX
      if isNumber(FX) then
         --do nix
      else 
         put codePointToNum(FX) into FZ
         put RRANGE(FZ) into FQ
         put ("This contains" && FQ && "script") into fld f2
      end if
      delete the first char of FFFF
   end repeat
   set the lockScreen to false
end mouseUp


function RRANGE FZ
   if FZ > 39 and FZ < 123 then
      return "Latin"
   end if
   if FZ > 191 and FZ < 592 then
      return "Latin"
   end if
   if FZ > 11359 and FZ < 11392 then
      return "Latin"
   end if
   if FZ > 42783 and FZ < 42958 then
      return "Latin"
   end if
   if FZ = 42963 then
      return "Latin"
   end if
   if FZ > 42964 and FZ < 42973 then
      return "Latin"
   end if
   if FZ > 42993 and FZ < 43008 then
      return "Latin"
   end if
   if FZ > 43823 and FZ < 43882 then
      return "Latin"
   end if
   if FZ > 67455 and FZ < 67462 then
      return "Latin"
   end if
   if FZ > 67462 and FZ < 67505 then
      return "Latin"
   end if
   if FZ > 67505 and FZ < 67515 then
      return "Latin"
   end if
   if FZ > 122623 and FZ < 122655 then
      return "Latin"
   end if
   if FZ > 122660 and FZ < 122667 then
      return "Latin"
   end if
   if FZ > 7679 and FZ < 7936 then
      return "Latin"
   end if
end RRANGE
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

Now let's "Go Rockabilly" . . . erm . . . get into Cyrillic:
-
Screenshot 2025-04-09 at 17.43.33.png
Screenshot 2025-04-09 at 17.43.33.png (23.2 KiB) Viewed 1920 times
-
These ranges are ; Hex 0400 - 04FF / Decimal 1024 - 1279
Hex 0500 - 052F / Decimal 1280 - 1327
Hex 2DE0 - 2DFF / Decimal 11744 - 11775
Hex A640 - A69F / Decimal 42560 - 42655
Hex 1C80 - 1C8A / Decimal 7296 - 7306
Hex 1E030 - 1E06D / Decimal 122928 - 122989
Hex 1E08F / Decimal 123023

Obviously the first 2 ranges can be combined.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

HOWEVER my code DOES not currently work as it returns "Latin" for a field that contains only non-latin script. :(

Changing this:

if FZ > 42783 and FZ < 42958 then

to this:

if FZ > 42783 and FZ < 42958 then

makes no difference.

BUT:

if FZ >= 42784 and FZ <= 42957 then

does work: so, obviously a "Bad Logic day for Richmond". :lol:

And another example of under documentation.

BUT: on testing that does NOT seem to work either.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

Ah: just Richmond being stupid on a major scale and forgetting that 'A' is NOT 41 but 65 ('A' is hex 41)!

One of the problems is that if none of the conditions of my function are satisfied the function returns a ZERO value which throws the script.

As a "." is NOT inwith any of my ranges I get a silly result:
-
Screenshot 2025-04-09 at 19.55.44.png
Screenshot 2025-04-09 at 19.55.44.png (16.32 KiB) Viewed 1838 times
-
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: isNumber

Post by richmond62 »

So: here we are . . .
-
Screenshot 2025-04-09 at 21.03.43.jpg
Screenshot 2025-04-09 at 21.03.43.jpg (185.65 KiB) Viewed 1835 times
-
This should be viewed as an intermediate sort of stack as, ideally, there should just be a single button for each field called 'Script Check'.
Attachments
Writing Script Checker.oxtstack
(11.19 KiB) Downloaded 89 times
https://richmondmathewson.owlstown.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests