converting string characters to char characters 
Author Message
 converting string characters to char characters

easy q:
want to convert single char string to a var of type char - see below. Is there
an easy way to do it? TIA.....

----------------------------------
var s,t:string;
     ch:char;

begin
s:='abcde';
t:=copy(s,1,1);
ch:=t; {doesn't compile with bp 7 or fpc !)
ch:=char(t); {typecaste- also doesn't compile with bp 7 or fpc....}
end.


-- opinions are mine--



Wed, 18 Jun 1902 08:00:00 GMT  
 converting string characters to char characters

Quote:

> easy q:
> want to convert single char string to a var of type char - see below. Is there
> an easy way to do it? TIA.....

what about

var
  ch : char;
  s : string;
begin
  ch := s[1]
end.



Wed, 18 Jun 1902 08:00:00 GMT  
 converting string characters to char characters

Quote:

>easy q:
>want to convert single char string to a var of type char - see below. Is there
>an easy way to do it? TIA.....

>----------------------------------
>var s,t:string;
>     ch:char;

>begin
>s:='abcde';
>t:=copy(s,1,1);
>ch:=t; {doesn't compile with bp 7 or fpc !)
>ch:=char(t); {typecaste- also doesn't compile with bp 7 or fpc....}

ch:=t[1];

or just  ch:=s[1];

After all a string is an array of chars.  Make sure that the string is
not empty or unpredictable result will occur.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 converting string characters to char characters

Quote:

> s:='abcde';
> t:=copy(s,1,1);
> ch:=t; {doesn't compile with bp 7 or fpc !)

  What about using ch := s[1]

Mike{*filter*}son, Black Cat Software Factory, Edinburgh, Scotland
fax 0131-271-1551 - Columnated Ruins Domino - Mellotron M400 #996



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Syntax error converting SMALLDATETIME from character string - problem

2. IBLOCAL: Cannot transliterate char between character sets!

3. Converting Character to ASCII

4. to pick a string into a array of characters

5. strings longer then 255 characters

6. strings longer then 255 characters

7. Erasing characters in a string.

8. String/Character-problem

9. String/Character Ques

10. String/Character Question

11. Interbase strings and unusual ascii characters

12. String constants longer than 255 characters?

 

 
Powered by phpBB® Forum Software