Recent

Author Topic: Language(lazarus0  (Read 1389 times)

hvh

  • New Member
  • *
  • Posts: 19
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: 854
  • 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

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62652 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

winni

  • Hero Member
  • *****
  • Posts: 891
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: 3310
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: 623
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
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

hvh

  • New Member
  • *
  • Posts: 19
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: 1445
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: 623
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

Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

PascalDragon

  • Hero Member
  • *****
  • Posts: 963
  • 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: 623
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
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

PascalDragon

  • Hero Member
  • *****
  • Posts: 963
  • 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: 2312
Re: Language(lazarus0
« Reply #11 on: January 18, 2020, 03:43:04 pm »
Interesting... Hmm...

Number 1 at blue screen app creations!