I've stored an array in an html hidden input and now need to transfer that array to my delphi function. I've tried:

  fileArray : array of string;

fileArray := formvar('fileArray', '');

but this gives an incompatible types error when I compile. How can I convert the string into an array so that it can be stored in the variable? Also, if it helps, the formvar fileArray is comma delimited.

Recommended Answers

All 6 Replies

IS "formvar" part of Delphi or your own method? I could not find a reference for it and am not familiar with it. Either way, what is the declaration for the function? Have you looked at tstringlist?

Also check out extractstrings in the Classes unit.

Put that string in a variable.

var a:String;

{in pascal,strings can be handle as array}
a:= 'Hello';

a[0]:= 5;   {this is a number of chars,here:5}

or see my another example:

Program StringIntoArray;

Uses Crt;
Const max = 11;
Var S:String[max];
    Ar:Array[1..max]of Char;

Begin {main}
     Write('Give me the word,max 11 char: ');
     For i:=1 To size Do
           If (i = size) Then Break;

     {Now write the results}
     For i:=1 To size Do WriteLn(Ar[i]);

End. {main}
(*Created By FlamingClaw 2009.03.11*)


You could also use "absolute" to align the two variables in memory by declaring:

  S : string;
  B : Array of Byte Absolute S;

This allows you to read and write to the string or array using the same memory area. It is similar to Union in C++.

But I do not think this is what yssirhc is after.


I think you did not understand me.I'm not speaking of number of bytes of a string...
If you have a string then you can put it into an array if you divide that string for characters...In my above example,that's a pascal example,can be look that....
But if we speaking about delphi then see the down link for more information...

I thought formVar was part of Delphi, but as you can probably tell I'm not all that familiar with this language & didn't write that part of the code.

Using a TStringList worked well though.

fileList := TStringList.Create;
fileList.CommaText := formvar('fileArray', '');
for count := 0 to fileList.Count-1 do

Thanks for the suggestions! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.