Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Delphi Pascal & Builder C++ Character Problem

This thread is locked; no one can reply to it. rss feed Print
Delphi Pascal & Builder C++ Character Problem
Grudge
Member #958
February 2001
avatar

In Pascal (Delphi), if I wanted to use control characters, I would use

// setup control characters
STX := Chr(2);
ETX := Chr(3);
ESC := Chr(27);
...

but how would I go and do it for c++ in builder, there is no Chr command (not in Builder C++ 6 anyways). Any ideas ?

--
Tom Van den Bon - Pixelate Editor
--
[ Pixelate ] - "...thats not a bug, it's a feature..."

X-G
Member #856
December 2000
avatar

char stx = 2;
char etx = 3;
char esc = 27;

Remember, chars are integral types. ::)

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Grudge
Member #958
February 2001
avatar

ok, but if I use it in a ansistring, would the following work

AnsiString Output = stx + "whatevertext";

would the output be : '3whatever' ? or would it have the actual control character in the string (instead of 3) ?

--
Tom Van den Bon - Pixelate Editor
--
[ Pixelate ] - "...thats not a bug, it's a feature..."

X-G
Member #856
December 2000
avatar

I don't know what an AnsiString is, but the char will have the value 3. Not the literal '3', which is ascii value 51.

char a;

// These two are equivalent
a = '3';
a = 51;

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Niunio
Member #1,975
March 2002
avatar

Try next:

char *ETX = {'3', 0};

Now, you can use strcat.

-----------------
Current projects: Allegro.pas | MinGRo

X-G
Member #856
December 2000
avatar

A string isn't the same as a char. Depends on what you want to use it for, of course.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Go to: