Re: [fpc-pascal] Pointers

2010-02-12 Thread Frank Peelo
Jonas Maebe wrote: On 11 Feb 2010, at 18:17, Rainer Stratmann wrote: In the past with the turbopascal compiler and other always sizeof byte was added. That is not true. This program prints "2" when compiled under Turbo Pascal: {$t-} type pw = ^word; var w: pw; begin w:=nil; inc(w)

Re: [fpc-pascal] Pointers

2010-02-11 Thread Mattias Gaertner
On Thu, 11 Feb 2010 21:53:59 +0100 Rainer Stratmann wrote: > Am Thursday 11 February 2010 21:24:03 schrieb Ralf A. Quint: > > At 12:07 PM 2/11/2010, Jonas Maebe wrote: > > >On 11 Feb 2010, at 18:17, Rainer Stratmann wrote: > > >>In the past with the turbopascal compiler and other always sizeof >

Re: [fpc-pascal] Pointers

2010-02-11 Thread David Emerson
On Thu 11 Feb 2010, Rainer Stratmann wrote: > How can I have access to position 4 of a pointer? > > var > p : pbyte; > c : char; > s : ansistring; > x : longint; > > s := 'Hello'; > p := @s; > x := 4; // 4th position > c := [p+x]^ ??? how to get access to the 'o' c := (p+x)^; // why w

Re: [fpc-pascal] Pointers

2010-02-11 Thread Ralf A. Quint
At 12:53 PM 2/11/2010, Rainer Stratmann wrote: > I am fairly certain that he confuses this with the special case of > applying sizeof() to a string type, where you always get one byte > more (the preceding length byte) than the string type has been > defined, for example SizeOf (String [80]) will

Re: [fpc-pascal] Pointers

2010-02-11 Thread Rainer Stratmann
Am Thursday 11 February 2010 21:24:03 schrieb Ralf A. Quint: > At 12:07 PM 2/11/2010, Jonas Maebe wrote: > >On 11 Feb 2010, at 18:17, Rainer Stratmann wrote: > >>In the past with the turbopascal compiler and other always sizeof > >>byte was > >>added. > > > >That is not true. This program prints "2

Re: [fpc-pascal] Pointers

2010-02-11 Thread Ralf A. Quint
At 12:07 PM 2/11/2010, Jonas Maebe wrote: On 11 Feb 2010, at 18:17, Rainer Stratmann wrote: In the past with the turbopascal compiler and other always sizeof byte was added. That is not true. This program prints "2" when compiled under Turbo Pascal: I am fairly certain that he confuses thi

Re: [fpc-pascal] Pointers

2010-02-11 Thread Rainer Stratmann
Am Thursday 11 February 2010 21:07:17 schrieb Jonas Maebe: > On 11 Feb 2010, at 18:17, Rainer Stratmann wrote: > > In the past with the turbopascal compiler and other always sizeof > > byte was > > added. > > That is not true. This program prints "2" when compiled under Turbo > Pascal: Ok, sorry I

Re: [fpc-pascal] Pointers

2010-02-11 Thread Jonas Maebe
On 11 Feb 2010, at 18:17, Rainer Stratmann wrote: In the past with the turbopascal compiler and other always sizeof byte was added. That is not true. This program prints "2" when compiled under Turbo Pascal: {$t-} type pw = ^word; var w: pw; begin w:=nil; inc(w); writeln(long

Re: [fpc-pascal] Pointers

2010-02-11 Thread Micha Nelissen
Rainer Stratmann wrote: Ok, that makes some sense, but I did not know it before. In the past with the turbopascal compiler and other always sizeof byte was added. The behavior is dependent on the {$T+} (typed pointers) mode. Micha ___ fpc-pascal mai

Re: [fpc-pascal] Pointers

2010-02-11 Thread Rainer Stratmann
I thought that adding something to a pointer always adds 1 sizeof(byte) to it. So if something is added to a pointer the compiler looks the sizeof the (typed) pointer points to? Ok, that makes some sense, but I did not know it before. In the past with the turbopascal compiler and other always size

Re: [fpc-pascal] Pointers

2010-02-11 Thread Frank Peelo
So you're allowed add an integer to an untyped pointer?! Wow! Usually if you add 1 to a pointer of type t, then sizeof(t) gets added to the value of the pointer. So if p points at an array of byte, p+1 would point at the next element of the array, 1 byte after p. But if p points at an array o

Re: [fpc-pascal] Pointers in Pascal!!

2008-05-01 Thread Mattias Gaertner
On Thu, 01 May 2008 15:23:29 +0200 Marc Weustink <[EMAIL PROTECTED]> wrote: > Mattias Gaertner wrote: >[...] > > ReAllocMem(p,0); > > Ah, now I understand why you use them :) > > Anyway does it set p:=nil ? Yes. Mattias ___ fpc-pascal maillist - fp

Re: [fpc-pascal] Pointers in Pascal!!

2008-05-01 Thread Marc Weustink
Mattias Gaertner wrote: On Wed, 30 Apr 2008 01:22:47 +0200 Marc Weustink <[EMAIL PROTECTED]> wrote: Alan Krause wrote: Hans MÃ¥rtensson wrote: But that would not work after the pointer was used and then it's memory freed. So a better way might be: Always when declaring pointers do it this w

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Mattias Gaertner
On Wed, 30 Apr 2008 01:22:47 +0200 Marc Weustink <[EMAIL PROTECTED]> wrote: > Alan Krause wrote: > > Hans MÃ¥rtensson wrote: > >> But that would not work after the pointer was used and then it's > >> memory freed. > >> So a better way might be: > >> > >> Always when declaring pointers do it this

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Marc Weustink
Alan Krause wrote: Hans MÃ¥rtensson wrote: But that would not work after the pointer was used and then it's memory freed. So a better way might be: Always when declaring pointers do it this way: var p: ^sometype = nil; Then in stead of using the freemem, define your own procedure: procedur

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Alan Krause
Hans MÃ¥rtensson wrote: But that would not work after the pointer was used and then it's memory freed. So a better way might be: Always when declaring pointers do it this way: var p: ^sometype = nil; Then in stead of using the freemem, define your own procedure: procedure myfreemem(var p: p

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Hans MÃ¥rtensson
Joao Morais wrote: Jonas Maebe wrote: On 29 Apr 2008, at 15:35, Zaka E-Lab wrote: It's possible to give a default initialization value to a defined type? No, that is not possible. Except if your pointer is declared as a member of a class (which is always assigned to nil by default)

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Joao Morais
Jonas Maebe wrote: On 29 Apr 2008, at 15:35, Zaka E-Lab wrote: It's possible to give a default initialization value to a defined type? No, that is not possible. Except if your pointer is declared as a member of a class (which is always assigned to nil by default) ___

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Jonas Maebe
On 29 Apr 2008, at 15:35, Zaka E-Lab wrote: It's possible to give a default initialization value to a defined type? No, that is not possible. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/li

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Zaka E-Lab
It's possible to give a default initialization value to a defined type? I suppose that it isn't, but it would be to easy to resolve that trouble that way. Anyway, I appreciate your help and support. Thanks. Zaka. Jonas Maebe escribió: It cannot know that without help. You have to do such book

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Jonas Maebe
On 29 Apr 2008, at 14:48, Zaka E-Lab wrote: I don't create anything, the memory is allocated by the create procedure. How can the procedure know if the argument is a pointer already allocated or not? It cannot know that without help. You have to do such bookkeeping yourself (e.g., as mentio

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Zaka E-Lab
Maybe I haven't explain it correctly. What I want is to construct a Unit that contains some procedures, one of them is create(var p : PStruct), and other is delete(var p : PStruct). I don't create anything, the memory is allocated by the create procedure. How can the procedure know if the argumen

Re: [fpc-pascal] Pointers in Pascal!!

2008-04-29 Thread Leonardo M. Ram�
You can assign "nil" to the pointer before using it, then check if PStruct = nil it wasn't created. Leonardo. --- Zaka E-Lab <[EMAIL PROTECTED]> wrote: > I have something like this: > > PStruct = ^Struct; > Struct = record > num: integer; > end; > > I have a unit to ha

RE: [fpc-pascal] Pointers

2005-07-28 Thread Lee, John
FPC-Pascal users discussions Subject: Re: [fpc-pascal] Pointers On Thursday 28 July 2005 06:11, Leonhard Holz wrote: > If you really want mode $13 you need to compile for dos, cause then > windows sets up an old-style 8086 environment. Unfortunately the > download page says: >

Re: [fpc-pascal] Pointers

2005-07-28 Thread Tomas Hajny
> On Thursday 28 July 2005 06:11, Leonhard Holz wrote: > >> If you really want mode $13 you need to compile for dos, cause then >> windows sets up an old-style 8086 environment. Unfortunately the >> download page says: >> >> "Sorry, no Dos release yet. The Dos platform is missing a maintainer >> an

Re: [fpc-pascal] Pointers

2005-07-28 Thread Vinzent Hoefler
On Thursday 28 July 2005 06:11, Leonhard Holz wrote: > If you really want mode $13 you need to compile for dos, cause then > windows sets up an old-style 8086 environment. Unfortunately the > download page says: > > "Sorry, no Dos release yet. The Dos platform is missing a maintainer > and is not

Re: [fpc-pascal] Pointers

2005-07-28 Thread Daniel Franzini
On 7/28/05, Leonhard Holz <[EMAIL PROTECTED]> wrote: > Hello, > > If you compile a win32-program you will have a total virtual memory, > that means that your pointer values don't have anything to do with the > physical ram. A pointer associated to $a actually points to nowhere. > ok...thanks

Re: [fpc-pascal] Pointers

2005-07-27 Thread Leonhard Holz
Hello, Note that those addresses (like $a000) are all things from the 16-bit world. I'm not sure how far these are emulated correctly if you are running in a 32-bit world. Addresses for graphics cards are way different there, easier to use, but different from card to card. If you compile a win

Re: [fpc-pascal] Pointers

2005-07-27 Thread John Coppens
On Wed, 27 Jul 2005 20:55:34 -0300 Daniel Franzini <[EMAIL PROTECTED]> wrote: > Hi everyone > > I'm just trying to compile and execute a simple example from a > graphics programming tutorial under FPC. Here is the code > Note that those addresses (like $a000) are all things from the 16-bit worl

Re: [fpc-pascal] Pointers

2005-07-27 Thread Elio Cuevas Gómez
El Mié 27 Jul 2005 20:14, Daniel Franzini escribió: > no, i didn't...but it worked and the program did compiled...now, it > shows the following message > > Runtime error 216 at $00401034 > $00401034 > > but i think that this is some windows (2000) issue not FPC one... New versions of WinNT (Incl.

Re: [fpc-pascal] Pointers

2005-07-27 Thread Steve Williams
Daniel Franzini wrote: no, i didn't...but it worked and the program did compiled...now, it shows the following message Runtime error 216 at $00401034 $00401034 but i think that this is some windows (2000) issue not FPC one...so i ask: is there any way of running these simple examples or i wil

Re: [fpc-pascal] Pointers

2005-07-27 Thread [EMAIL PROTECTED]
Maybe free pascal supports the "absolute" directive ;) something like: var SomeAddress : pointer absolute $a000; - Original Message - From: "Daniel Franzini" <[EMAIL PROTECTED]> To: Sent: Thursday, July 28, 2005 1:55 AM Subject: [fpc-pascal] Pointers Hi everyone I'm just trying

Re: [fpc-pascal] Pointers

2005-07-27 Thread Steve Williams
Daniel Franzini wrote: BEGIN InitGraph; Screen := MEM[$A000]; { Set up the screen buffer pointer } <---here is the error WHILE NOT KeyPressed DO SetPixel( RANDOM(320), { Random X (Range 0-319) } RANDOM(200), { Random Y (Range 0-199) } RAN