Recent

Author Topic: Language(lazarus0  (Read 2514 times)

hvh

  • New Member
  • *
  • Posts: 20
Language(lazarus0
« on: January 16, 2020, 11:02:59 pm »
I  start again with Lazarus  after a long time and do not know what means #8
or fr example  #13 like in a program rule    if not {Key in) ['1', '2','3',#8] then etc.
I know it is very stupid but I could not find the andwer.
It need little time to andere it.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Language(lazarus0
« Reply #1 on: January 16, 2020, 11:53:08 pm »
#8 = backspace
#13 = carriage return

Google ASCII.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Language(lazarus0
« Reply #2 on: January 17, 2020, 12:11:00 am »
Hi!

Look in the unit LCLtypes, starting at line 390:

There are the virtual key constants - some with explanation like

Code: Pascal  [Select][+][-]
  1.  VK_RETURN     = 13; // The "Enter" key, also used for a keypad center press  

Winni

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Language(lazarus0
« Reply #3 on: January 17, 2020, 04:28:08 am »
The #number notation is a Pascal convenience (introduced I think by Borland) to enable you to easily indicate characters such as Chr(13) which do not have an alphabetical equivalent, so cannot be represented using the 'character' syntax such as 'a', '4' etc.
You can use the Chr() function (or simply typecast using Char(byte-value) ) as alternatives, but the # notation is more convenient and works well for specifying string and character constants.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Language(lazarus0
« Reply #4 on: January 17, 2020, 09:33:49 am »
The #number notation is a Pascal convenience (introduced I think by Borland) to enable you to easily indicate characters such as Chr(13) which do not have an alphabetical equivalent, so cannot be represented using the 'character' syntax such as 'a', '4' etc.
You can use the Chr() function (or simply typecast using Char(byte-value) ) as alternatives, but the # notation is more convenient and works well for specifying string and character constants.

I'd +1 that if the forum knew about such things :-)

"Google ASCII" isn't helpful without much more explanation, and referring to VK_ codes isn't helpful since they are a system-specific superset which actually represent keyboard input and as such go through several more layers of translation before they're visible to typical programs.

Hence representations like #8 #$08 Chr(8) and Chr($08) are all equivalent, and represent the backspace character.

The # representation can also be used inline in strings, which can appear in case statements. Let's not go there for the moment.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

hvh

  • New Member
  • *
  • Posts: 20
Re: Language(lazarus0
« Reply #5 on: January 17, 2020, 08:53:04 pm »
Many thanks to enveryone who came with aclear answer to my question.
It is  very helpfull.

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: Language(lazarus0
« Reply #6 on: January 17, 2020, 10:45:58 pm »
There is another option that is used less frequently. Variant of control symbols: ^C = #3 = Chr(3); ^H = #8 = Chr(8);
Example:
Code: Pascal  [Select][+][-]
  1. {$MODE OBJFPC}
  2. {$APPTYPE CONSOLE}
  3.  
  4. begin
  5.   Writeln('1'^I'2'^H'3');
  6.   Readln;
  7. end.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Language(lazarus0
« Reply #7 on: January 18, 2020, 11:17:52 am »
There is another option that is used less frequently. Variant of control symbols: ^C = #3 = Chr(3); ^H = #8 = Chr(8);

Is that actually supported by FPC, and if so since when?

There was a bit of discussion of the perils of this stuff when there was a possibility of supporting EBCDIC-based mainframes. These days UTF-8 etc. is even more perilous: how should ^Ç be parsed?

MarkMLl

MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Language(lazarus0
« Reply #8 on: January 18, 2020, 11:35:05 am »
FPC supports this since essentially forever (before the migration to SVN at least). It's documented here and only supports ASCII characters. It's called Caret notation and was also supported in either TP or early Delphi versions (and still is supported there).

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Language(lazarus0
« Reply #9 on: January 18, 2020, 12:18:52 pm »
FPC supports this since essentially forever (before the migration to SVN at least). It's documented here and only supports ASCII characters. It's called Caret notation and was also supported in either TP or early Delphi versions (and still is supported there).

I know exactly what it is, and have been using it since KSR33s were the "bee's knees". I just didn't know that FPC supported it.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Language(lazarus0
« Reply #10 on: January 18, 2020, 01:13:07 pm »
FPC supports this since essentially forever (before the migration to SVN at least). It's documented here and only supports ASCII characters. It's called Caret notation and was also supported in either TP or early Delphi versions (and still is supported there).

I know exactly what it is, and have been using it since KSR33s were the "bee's knees". I just didn't know that FPC supported it.
I came across it by accident some years back... ;)

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Language(lazarus0
« Reply #11 on: January 18, 2020, 03:43:04 pm »
Interesting... Hmm...

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018