Is there a way to get the asci code of a char?
Displaying 1-8 of 8 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Buckermann

I wish to replace parts of a textfile which makes Verge crash.
For example, replacing tabs (or whatever 0D and 0A is) with 4 spaces.
Any easy way? Or do I have to check the file itself byte by byte?

Posted on 2004-06-12 18:03:21

Zip

Standard c way would be if(key['a']) with 'a' giving you the ascii code of a little a. However, quickly looking in v3vergec.txt reveals a bunch of built in defines that aren't ascii standard, eg:
{"SCAN_Z", "44" }
{"SCAN_X", "45" }
{"SCAN_C", "46" }
{"SCAN_V", "47" }
{"SCAN_B", "48" }
{"SCAN_N", "49" }
{"SCAN_M", "50" }

This one looks useful:
{"SCAN_TAB", "15" }

Zip

Posted on 2004-06-12 18:18:17

Buckermann

Well, that are the keyboard scan codes. For example the scan code for Tab is 15, but the ascii value for Tab is 9.
I need something like
int AsciiValue = ascii(somestring);
to check every single char of a string if it is a illegal char who could crash verge.

Posted on 2004-06-12 18:30:09

Zip

In which case back to what is said first.

PrintString(10, 10, screen, 0, str('a'));
// Outputs 97, which is right isn't it?

There doesn't seem to be a reverse function of string char(ascii_code); though - int val(string); only returns for numerics, and you can't use int = 'string_variable';

Zip

[Edit: Never done much string handling. Have a look at these:
TokenCount
GetToken]
[Edit73: Dear god I'm not making a lot of sense today.]

Posted on 2004-06-12 18:41:33 (last edited on 2004-06-12 19:01:32)

el_desconocido

Quote:Originally posted by Buckermann

Well, that are the keyboard scan codes. For example the scan code for Tab is 15, but the ascii value for Tab is 9.
I need something like
int AsciiValue = ascii(somestring);
to check every single char of a string if it is a illegal char who could crash verge.

Try:
if(strcmp(test_char, "~") > 0) test_char = "_";

That should filter out all the illegal characters verge doesn't filter out itself.

Since adding this to ILL2, I have yet to see verge choke on my strings. Note also that it seems only printstring() chokes, all other string manipulation and storage work fine with all characters, in my experience.

El

Posted on 2004-06-12 19:00:23

Gayo

VERGE can't handle ~? That's pretty weird.

Posted on 2004-06-12 22:52:36

Kildorf

Dude, strcmp will only return > 0 if it's bigger than ~... ~ is not bigger than ~ so the replace won't happen. ^_^

Posted on 2004-06-12 22:55:37

Buckermann

El Desconocido,
your suggestion resolved most of the my problems, but to get rid of the Tabs I had to add a extra check

if(!strcmp(TestChar, chr(9)))
TestChar = " ";

Thanks for your help :)

Posted on 2004-06-13 00:14:24


Displaying 1-8 of 8 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.