Board index » delphi » Converting a string var to ascii

Converting a string var to ascii

I have a feeling this is simple, but damn...

x : string;
x := char(65);
..

x will be 'A'.

There isn't an asc(x) function, so what is the equivilant?

This sort of what I was hoping for; the ASCII code for the last character
of an Edit field's name:

nY := asc(Copy((Sender as TEdit).Name, length(Sender as TEdit).Name, 1));

(This is just an example - I know there are imcopmpatibilities in the
syntax..hehe)

Kind regards,
BL

 

Re:Converting a string var to ascii


Quote
Bob Lehy wrote:

> I have a feeling this is simple, but damn...

> x : string;
> x := char(65);
> ..

> x will be 'A'.

I think you want the Ord function.
Quote

> There isn't an asc(x) function, so what is the equivilant?

> This sort of what I was hoping for; the ASCII code for the last character
> of an Edit field's name:

> nY := asc(Copy((Sender as TEdit).Name, length(Sender as TEdit).Name, 1));

> (This is just an example - I know there are imcopmpatibilities in the
> syntax..hehe)

> Kind regards,
> BL

Re:Converting a string var to ascii


use ord

eg this should work (fingers crossed)

with Sender as tEdit do
  nY := ord (Name[Length(Name)]);

(not tested)

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

Re:Converting a string var to ascii


Thanks - That's the ticket.  I figured it was ord(), but I wasn't using
the string var properly.

Kind Regards,
Bob

/////////////////////////////////////////////////////////////////////////
Remember: If you lend someone $20, and never see that person again, it
was probably worth it.

In article <38c924ed.20580...@news.gte.net>, koter...@gte.net says...

Quote
> On Mon, 06 Mar 2000 21:09:37 GMT, bob...@nospam.hotmail.com (Bob Lehy)
> wrote:

> >I have a feeling this is simple, but damn...

> >x : string;
> >x := char(65);
> >..

> >x will be 'A'.

> >There isn't an asc(x) function, so what is the equivilant?

> See the Ord function.

>   var
>     i: Integer;
>     x: String;
>   begin
>     x := 'Bob Lehy';
>     i := Ord(x[1]); { which yields 66 for the capital "B" }
>   end;

> ///////////////////////////////////////////////////////////
> Steve Koterski              "No matter how cynical you get,
> Felton, CA                  it is impossible to keep up."
>                                              -- Lily Tomlin

Other Threads