How to use ASCII values in C/SIDE

Article ID: 874538 - View products that this article applies to.
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

TechKnowledge Content

Issue

How to use ASCII values in C/SIDE?

Resolution


There are two examples. The first example shows how to get an ASCII value from a string (Text or Code). The second example shows how to write values to a string using ASCII values.

Example 1 - How to get an ASCII value from a string


Use the following variables for the example:

VAR
SourceText : Text[30];
SourceCode : Code[10];
B : Char;
ASCIIvalue : Integer;


Follow the code below:

SourceText := 'Text';SourceCode := 'CODE';

B := SourceText[2];
ASCIIvalue := B;
MESSAGE(FORMAT(ASCIIvalue));

How it works:

SourceText is treated as an array of chars.
SourceText[2] is the second character in string.
ASCIIvalue receives the ASCII value of the char.
MESSAGE showing ASCII value (101).

B:= SourceCode[3];

ASCIIvalue := B;
MESSAGE(FORMAT(ASCIIvalue));


How it works:

SourceCode is treated as an array of chars.
SourceText[3] is the third character in string.
ASCIIvalue receives the ASCII value of the char.
MESSAGE showing ASCII value (68).

Example 2 - How to write ASCII values to a string


Use the following variables for the example:

VAR

TargetText : Text[250];
TargetFile : File;
B : Char;
I : Integer;


Follow the code below to display characters on the screen or write to a file:

FOR I := 32 TO 255 DO BEGIN

B := I;
TargetText[I - 31] := B;
END;
MESSAGE(TargetText);

FOR I := 1 TO 250 DO BEGIN
B := I;
TargetText[I] := B;
END;

TargetFile.CREATE('Ascii.txt');
TargetFile.WRITEMODE(TRUE);
TargetFile.WRITE(TargetText);
TargetFile.CLOSE;


This article was TechKnowledge Document ID: 33356

Properties

Article ID: 874538 - Last Review: November 2, 2013 - Revision: 3.0
Applies to
  • Microsoft Business Solutions–Navision 3.70
Keywords: 
kbnosurvey kbarchive kbmbsdevelopmenttools kbmbsmigrate KB874538

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com