Re: [Lazarus] Passing a section of an array to a function.

2012-09-11 Thread Marco van de Voort
On Mon, Sep 10, 2012 at 02:29:14PM +0200, Sven Barth wrote: > > The delphi compatible way is slice, but ti was only documented after the > > last release: > > > > http://bugs.freepascal.org/view.php?id=22681 > > I did know about Slice, but not about the possiblity to use ranges > directly (and no

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread Sven Barth
Am 10.09.2012 13:21, schrieb Marco van de Voort: On Mon, Sep 10, 2012 at 10:47:33AM +0200, Sven Barth wrote: func(buf[32 .. ]); reference: http://www.freepascal.org/docs-html/ref/refsu59.html And it's still true: even I as a compiler developer can learn something new as I didn't know yet that

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread Marco van de Voort
On Mon, Sep 10, 2012 at 10:47:33AM +0200, Sven Barth wrote: > > > > func(buf[32 .. ]); > > reference: http://www.freepascal.org/docs-html/ref/refsu59.html > > And it's still true: even I as a compiler developer can learn something > new as I didn't know yet that this was possible. The delphi com

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread Mark Morgan Lloyd
Sven Barth wrote: Am 10.09.2012 10:39, schrieb leledumbo: If you know the amount of bytes you want to copy then you should use "Copy(buf, 32, count)" as argument for decompress_r or if you don't know the amount you should change your function from "array of Byte" to "PByte" and pass the address

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread Dave Coventry
On 10 September 2012 10:14, Sven Barth wrote: > Did you really write "&"? The address operator is "@", but this won't make > your code work anyway. If you did indeed write "&" (which is for escaping > keywords) you do indeed only pass the 32nd element to your function. :blush: I did indeed. That

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread Sven Barth
Am 10.09.2012 10:39, schrieb leledumbo: If you know the amount of bytes you want to copy then you should use "Copy(buf, 32, count)" as argument for decompress_r or if you don't know the amount you should change your function from "array of Byte" to "PByte" and pass the address of the 32nd byte u

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread leledumbo
yte using "@buf[32]" Or use the array slicing construct: func(buf[32 .. ]); reference: http://www.freepascal.org/docs-html/ref/refsu59.html -- View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Passing-a-section-of-an-array-to-a-function-tp4026434p

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread Howard Page-Clark
On 10/9/12 7:36, Dave Coventry wrote: Hi, I have an array of Byte which I have loaded from a file. I want to process a 100 byte section of the array which starts at offset 32 in my array. My function (or procedure) is as follows: procedure decompress_r(cbuf: array of byte); var len,i: inte

Re: [Lazarus] Passing a section of an array to a function.

2012-09-10 Thread Sven Barth
Am 10.09.2012 08:36, schrieb Dave Coventry: Hi, I have an array of Byte which I have loaded from a file. I want to process a 100 byte section of the array which starts at offset 32 in my array. My function (or procedure) is as follows: procedure decompress_r(cbuf: array of byte); var len,i

[Lazarus] Passing a section of an array to a function.

2012-09-09 Thread Dave Coventry
Hi, I have an array of Byte which I have loaded from a file. I want to process a 100 byte section of the array which starts at offset 32 in my array. My function (or procedure) is as follows: procedure decompress_r(cbuf: array of byte); var len,i: integer; begin i:=1; if (cbuf[0]and $F0)=