Page 1 of 1

Ascii codes

PostPosted: Tue Mar 27, 2012 10:49 am
by dpayer
I have run into a similar issue as was described here:

http://www.neosoftware.com/forum/viewtopic.php?t=19274

At times it is difficult to make distinctions between strings with mixed capitalization. It would be nice to have a NB function that returned the ascii code of a character as a counterpart to having the ability to use [#13] or other ascii codes as characters represented by the variable with their ascii number.

This may be a good one for me to experiment with a VB script to address the issue but if you have time to include it as a NB function, that would be nice too. If you do ( :) ) give an option for either decimal or hex.

David P

PostPosted: Tue Mar 27, 2012 12:44 pm
by Gaev
DavidP:

You could create a NeoBook Function that could be Call'ed from anywhere in your Apps.

Here is a SubRoutine version of the logic ...
Code: Select all
SetVar "[myCharacter]" "!D"
GoSub "Char2Ascii"
AlertBox "![myCharacter]" "![myAsciiCode]"


And the SubRoutine woiuld look like this ...
Code: Select all
:Char2Ascii
SetVar "[asciiCodes]" "!A032!033[#34]034#035$036 ... }125~126"

SearchStr "![myCharacter]" "![asciiCodes]" "[FoundPos]"
If "[FoundPos]" ">" "0"
   SubStr "![asciiCodes]" "1 + [FoundPos]" "3" "[myAsciiCode]"
Else
   SetVar "[myAsciiCode]" "!0"
EndIf

Return


Basically, [asciiCodes] consists of '4 characters' for 'each character whose ascii code you need'.

P.S. Note verfied by me ... so caveat emptor !!!

PostPosted: Tue Mar 27, 2012 3:00 pm
by dpayer
Good idea!

David


Gaev wrote:DavidP:

You could create a NeoBook Function that could be Call'ed from anywhere in your Apps.
P.S. Note verfied by me ... so caveat emptor !!!