[fpc-pascal] Dynamic Arrays in Procedures
James Richters
james at productionautomation.net
Sun Oct 4 21:58:55 CEST 2020
I'm wondering if there is a way to pass an array of values to a Procedure
without defining an array variable..
For example, if I have a Procedure:
Procedure DoSomething(X :Byte);
Then I can call it with a specific a variable like this:
Var
ThingA :Byte;
.
DoSomething(ThingA);
And I can also call it without a variable but instead just hard code a
specific value like this:
DoSomething($1A);
So if I have a procedure like this:
Procedure DoSomethingElse(Y :Array of Byte);
I can call it like this:
Var
ThingB :Array Of Byte;
SetLength(ThingB,3);
ThingB[0] :=$12;
ThingB[1] :=$1A;
ThingB[2] :=$2B;
DoSomethingElse(ThingB);
But can I also just call it with specific values somehow?
DoSomethingElse([$12,$1A,$2B]); for example. of course this doesn't work,
but is there a syntax that would work?
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20201004/2b6e1762/attachment-0001.htm>
More information about the fpc-pascal
mailing list