SRL Archive - General

The Opposite of the Chr() Command


canadarules

2006-06-06 22:52:10

The opposite of the Chr command is Ord.

Chr(54) = '6'.
Ord('6') = 54.

Lots of people don't know this. Feel smart now.

phantombmx

2006-06-06 22:58:44

now whats ord stand for smarty pants ;)

canadarules

2006-06-06 23:10:57

From: phantombmx
now whats ord stand for smarty pants ;)


Order XD

1 = first, 54 = 54th character ('6')

I remember first post=p

2006-06-06 23:53:32

Uhh… XD Nerds?

canadarules

2006-06-06 23:59:00

It's a function that COULD be useful. =P

I just answered his question.

PS, when am I no longer a "Junior Member"?

phantombmx

2006-06-07 00:07:45

From: canadarules
It's a function that COULD be useful. =P

I just answered his question.

PS, when am I no longer a "Junior Member"?


when you get more than 100 posts :rolleyes:

also yeah i could find a use for it :p

somethin like Ord(blah) then use that for a bitmap :cool:

driger1592

2006-06-07 08:08:38

Ord stands for ordinal you smart wanna-be :p

As for its uses, you can really use it for some interesting things ;) I'll see if I can find a few examples when I get home from school (I'm leaving in 2 minutes :p)

shaunthasheep

2006-06-07 12:05:59

instead of making a new thread. how can i make it hold and release the "crtl" key :P

driger1592

2006-06-07 17:08:52

One of the following ways:
KeyDown(17);
DoStuff;
KeyUp(17);
KeyDown(162);//left ctrl
DoStuff;
KeyUp(162);
KeyDown(163);//right ctrl
DoStuff;
KeyUp(163);
Chr/Ord does NOT apply to KeyDown/KeyUp. For other keys, you can either use the virtual key constants (Type VK_ into SCAR and hit space+ctrl for the full list), or search the forums for KDKUI (my KeyDown / KeyUp Include) for a FULL list of keys.

Now for Ord, you could use it for encrypted messages (I don't think that's actually practical because there's not much of a use for it), by doing chr(ord('a')+2); and so on for every letter, and use the output from chr in SendKeys ( Like SendKeys(chr(ord('a')+2)); ).

Another use is simply finding stuff the numbers for chr ( Such as Writeln(IntToStr(ord('a))); which you could even write a function for to get the chrs for whole strings ).

I think I'm missing a few uses here, but I haven't been doing much string manipulation lately. Hopefully this is a little helpful.

Cruel

2006-06-07 19:34:56

Since we're bring up random character related features, here are a couple:

You can also use the # operator for characters instead of key constants.
For instance:

writeln(#50+#51);
Writes the string "23" (ASCII 50 and 51).

And you can access characters of a string just like an array.
Like this:
str1:= 'abcdef';
writeln(str1[3]);
That will write the character "c".
Here's another example.
program New;
var
str1:String;
i:Integer;
begin
str1:= 'abcdefghijklmnopqrstuvwxyz';
for i:= 1 to length(str1) do
writeln('Character '''+str1[i]+''' at position '+inttostr(i)+'.');
end.

tada. :D

canadarules

2006-06-08 22:25:10

Fine, psh.

Anyways, Driger, I can't find anything related to Chr in your tutorial. Maybe I just missed it. If it isn't in there, you should try to add it. Ord isn't really extremely useful anyways.

aniityberg

2007-03-17 03:41:48

Hi!
My name is Anny. I 2 days on the Internet. Also it is very glad, that has got on your forum www.srl-forums.com.
This first my message at a forum in section this. Here so much the necessary information.
Thanks!

Markus

2007-03-17 09:42:53

From: aniityberg
Hi!
My name is Anny. I 2 days on the Internet. Also it is very glad, that has got on your forum www.srl-forums.com.
This first my message at a forum in section this. Here so much the necessary information.
Thanks!

And another bot, could someone please ban this guy? He doesn't even speak some proper English.

bullzeye95

2007-03-17 09:45:01

Why the hell did you gravedig that far???

deathbyvirus

2007-03-17 14:08:58

i don't see what this could be used for…