Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 03-11-2009, 05:44 PM
yssirhc yssirhc is offline
Junior Member
 
Join Date: Mar 2009
Posts: 7
Default converting string to array

I've stored an "array" in an html hidden input - it's actually a comma delimited string. And now I need to grab that array and store it as a variable so that my delphi code can loop through it. The problem I'm having is figuring out how to convert that string so that it can be stored in a delphi array variable. This is what I have:
[delphi]
fileString : string;
fileArray : array of string;

fileString := formvar('fileArray', ''); //the html hidden input is named fileArray also. It is a comma delimited string of file names.

//some loop using fileString to store contents in fileArray
[/delphi]
Can anybody help me with this?
Reply With Quote
  #2  
Old 03-11-2009, 05:49 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default RE: converting string to array

A normal string in Delphi is really an array of char. Example:

.................................................. ....
[DELPHI]var
i : Integer;
fileString : String;
begin
fileString := formvar('fileArray', '');

for i:=1 to Length(fileString) do begin
Showmessage( fileString[i] );

end;[/DELPHI]

Regards,
Abdulaziz Jasser
Reply With Quote
  #3  
Old 03-11-2009, 05:53 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default RE: converting string to array

Sorry try:


[DELPHI]var
i : Integer;
oSL : TStringList;
begin
oSL := TStringList.Create;
oSL.CommaText := formvar('fileArray', '');

for i:=0 to oSL.Count-1 do begin
Showmessage( oSL[i] );
end;

oSL.Free;[/DELPHI]

Regards,
Abdulaziz Jasser
Reply With Quote
  #4  
Old 03-18-2009, 05:34 PM
yssirhc yssirhc is offline
Junior Member
 
Join Date: Mar 2009
Posts: 7
Default RE: converting string to array

thanks a lot! I'm not all that familiar with Delphi. It was simpler than I thought : )
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 11:28 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.