Recent

Author Topic: Where is Special Characters Reference  (Read 4008 times)

flywire

  • Jr. Member
  • **
  • Posts: 85
Where is Special Characters Reference
« on: February 11, 2015, 01:41:09 pm »
Where is the reference for special characters such as hex and pointer etc?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: Where is Special Characters Reference
« Reply #1 on: February 11, 2015, 02:49:26 pm »
In the reference manual?  & is octal, % is binary and $ is hex.    # is character (and can be combined with the others, so #$15 is the character with hexcode 15)

flywire

  • Jr. Member
  • **
  • Posts: 85
Re: Where is Special Characters Reference
« Reply #2 on: February 12, 2015, 09:44:57 am »
Yes, this is what I was looking for.

    1.1 Symbols
    • The following characters have a special meaning:
      ... ^ @ ... $ # & %
    1.6 Numbers
    • $ Hex, & Octal, % Binary
    1.8 Character strings
    • # Char

Now, what about the ^ @ characters which first appear in 3.2 Character types?
^ is pointer and @ is an address but it doesn't mean much to me.


Thanks

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Where is Special Characters Reference
« Reply #3 on: February 12, 2015, 07:07:59 pm »
Code: [Select]
type
  TFoo = record X: Integer; end;
  PFoo = ^TFoo; //PFoo is a pointer to a TFoo structure
var
  Foo: TFoo;
  P: PFoo;
begin
  Foo.X := 1;
  P := @Foo; //P now points to Foo
  writeln(Foo.X); //shows 1
  writeln(P^.X); //shows 1, the ^ after is called dereferencing
  Foo.X := 2;
  P^.X := 3;
  writeln(Foo.X); //shows 3, since P^.X is the same as Foo.X
end.

Bart

flywire

  • Jr. Member
  • **
  • Posts: 85
Explaining the Special @ Address Character and ^ Pointer Character
« Reply #4 on: February 15, 2015, 01:19:07 pm »
A reference in the wiki under tutorials has a good page on pointers:  http://www.delphibasics.co.uk/Article.asp?Name=Pointers

Two snippets:
  • myCharPtr := Addr(myString);
    Neil explains that 'the @ character can equally be used instead of the Addr function'. This does it for me - it's just a function.
  • ShowMessage(myCharPtr^)
    "...we use the ^ character at the end of the pointer name to refer to what the pointer points to." So read it as 'points to' like := is read becomes.

flywire

  • Jr. Member
  • **
  • Posts: 85
How Pointers Work
« Reply #5 on: February 21, 2015, 08:17:45 am »
A good article on pointers by Rudy Velthuis: http://rvelthuis.de/articles/articles-pointers.html

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: Where is Special Characters Reference
« Reply #6 on: February 21, 2015, 11:00:13 am »
Note that (OBJ)FPC modes also require @ to assign/pass procedure variables. This was done to disambiguate some special case.

 

TinyPortal © 2005-2018