On Tue, Jan 31, 2012 at 11:19, Sven Barth <pascaldra...@googlemail.com>wrote:
> Am 31.01.2012 09:55, schrieb ik: > > Hello, >> >> I wish to create something like this: >> >> function foo(a : String; b : array of const) : string; >> begin >> Result := bar([a] + b); >> end; >> >> But this works only on Sets. >> The thing is, that A must be before the rest of "b". and it is different >> then the b values, that's why I extract it to a different parameter. >> >> How can I add a to the list, and make it the first element ? >> > > There is no easy way, only the following: > > function foo(a: String; b: array of const): String; > var > tmp: array of TVarRec; > i: LongInt; > begin > SetLength(tmp, Length(b) + 1); > tmp[0].VType := vtAnsiString; // Note: Only if "foo" is in a unit with > {$H+} set (or mode Delphi) > tmp[0].VAnsiString := Pointer(a); > for i := 0 to High(b) do > tmp[i + 1] := b[i]; > Result := bar(tmp); > end; > > Regards, > Sven > Thanks, that's what I was afraid of. :) Ido > ______________________________**_________________ > fpc-pascal maillist - > fpc-pascal@lists.freepascal.**org<fpc-pascal@lists.freepascal.org> > http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal> >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal