ASCII

ASCII operator converts an integer operand into its corresponding ASCII character:

ASCII number

number

an integer expression that returns a positive whole number within the range of ASCII values

You can use ASCII to convert an integer to a single character – it is particularly useful for displaying CONTROL characters.

4gl cannot distinguish between printable and non-printable ASCII characters.

Be sure to account for non-printable characters when using the COLUMN operator to format the screen or a page of report output.

In this example program, the DISPLAY statement rings the terminal bell (ASCII value of 7):

MAIN

  DEFINE

    bell_tone CHAR(1),

    inp_char CHAR(1)

 

  LET bell_tone = ASCII 7

 

  DISPLAY bell_tone -- Make the bell tone

  #Note - This is just an example

  #we strongly recommend to use the function fgl_bell() for a bell_tone

 

 

  DISPLAY "This bell tone example works only with the DISPLAY ... NOT with DISPLAY...AT" at 4,5

  DISPLAY "The bell tone does not work in a GUI environment" at 5,5

  DISPLAY "To get a bell tone" at 6,5

  DISPLAY "you should use the functin fgl_bell()" at 7,5

 

  DISPLAY "The control character: " at 10, 5

  DISPLAY bell_tone at 10, 30 -- displays the control character

 

  CALL fgl_getkey()

END MAIN

 

Here REPORT program block shows how to implement special printer or terminal functions:

FORMAT

FIRST PAGE HEADER

  LET red_on = ASCII 9, ASCII 11, ASCII 1

  LET red_off = ASCII 9, ASCII 11, ASCII 0

ON EVERY ROW

...

PRINT red_on, "Your bill is overdue.", red_off

It assumes that

Values used in this example are hypothetical and can work or not for your printer. Different printers and on-screen rendering applications handle spaces in different ways and use different control characters. It may only be possible to determine the appropriate spacing by trial and error.

ASCII operator in PRINT statements

ASCII operator should be followed by the integer expression that returns a positive integer to specify the code of the character to be printed.

ASCII operator generally works with the PRINT statement in the same way as it works with other statements.

The only exception is this: To print a null character in a report, you must call the ASCII operator with 0 in the PRINT statement:

PRINT ASCII 0

ASCII 0 only displays the null character within the PRINT statement. If you specify ASCII 0 in other contexts, it returns a blank space.

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.