Board index » delphi » String/char

String/char

I should have put this in my other post, but I forgot.
In my program, I am reading various inputs as strings. I want it to use the
function keys to allow special features - ESC ends the program, F1 brings up a
little help box, etc. How can I do this with a string - can I convert it to a
char ?
~Jonathan.
 

Re:String/char


Hi
You can convert a string to anything. I'll give you an example of how
you can do that.
Do you want it to be an error trap too??

procedure converttochar (inputstring:string);

var cConverted:char

begin
cConverted:=inputstring[1];
end;

And that's it. But if you want it to be an error trap catching any
other longer input then specify a string size (e.g. string[10]) and
make a loop (for to do) from 1 to 10 that checks that all places from 2
to 10 are empty . Empty is signified as '#0'.
e.g .

procedure errortrap (inputstring:string);

var I:integer;
    check:boolean;

begin
check:=true;
for I:=2 to 10 do {because you don't want the first place to be empty}
if inputstring[I]<>#0 then ckeck:=false ;

..............and so on .......

I hope that's helpful. If you want anything else post a message or mail
me
NoViE

Sent via Deja.com
http://www.deja.com/

Other Threads