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

var
  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.

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}
{example} 
a:= 'Hello';

a[0]:= 5;   {this is a number of chars,here:5}
a[1]:='H';
a[2]:='e';
a[3]:='l';
a[4]:='l';
a[5]:='o';

or see my another example:

Program StringIntoArray;

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


Begin {main}
     ClrScr;
     Write('Give me the word,max 11 char: ');
     ReadLn(S);
     size:=Length(S);
     For i:=1 To size Do
        Begin
           Ar[i]:=S[i];
           If (i = size) Then Break;
        End;

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

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

FlamingClaw,

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

Var
  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.

'jsosnowski'

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...
http://delphi.about.com/cs/adptips2002/a/bltip1102_5.htm

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, networking, learning, and sharing knowledge.