How to use ASCII values in C/SIDE

This article has been archived. It is offered "as is" and will no longer be updated.
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:







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:

VARTargetText : 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 BEGINB := I;TargetText[I - 31] := B;END;MESSAGE(TargetText);FOR I := 1 TO 250 DO BEGINB := 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: 11/02/2013 05:23:00 - Revision: 3.0

  • Microsoft Business Solutions–Navision 3.70
  • kbnosurvey kbarchive kbmbsdevelopmenttools kbmbsmigrate KB874538
Feedback