| | |
convert string to array
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Feb 2009
Posts: 24
Reputation:
Solved Threads: 0
I've stored an array in an html hidden input and now need to transfer that array to my delphi function. I've tried:
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.
delphi Syntax (Toggle Plain Text)
var fileArray : array of string; fileArray := formvar('fileArray', '');
Put that string in a variable.
pascal Syntax (Toggle Plain Text)
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';
Last edited by FlamingClaw; Mar 11th, 2009 at 5:35 pm.
or see my another example:
pascal Syntax (Toggle Plain Text)
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:
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.
You could also use "absolute" to align the two variables in memory by declaring:
Pascal and Delphi Syntax (Toggle Plain Text)
Var S : string; B : Array of Byte Absolute S;
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/adptips20...ltip1102_5.htm
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/adptips20...ltip1102_5.htm
Last edited by FlamingClaw; Mar 13th, 2009 at 8:30 am.
•
•
Join Date: Feb 2009
Posts: 24
Reputation:
Solved Threads: 0
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.
Thanks for the suggestions!
Using a TStringList worked well though.
delphi Syntax (Toggle Plain Text)
fileList := TStringList.Create; fileList.CommaText := formvar('fileArray', ''); for count := 0 to fileList.Count-1 do
Thanks for the suggestions!
![]() |
Similar Threads
- How to display unique string variables? (PHP)
- how to convert string array in integer array (C)
- convert integer to array of character??? (C++)
- string to array (C++)
- How do I convert a vector to a String array ? (Java)
- String to array (C++)
- Copy string into an array (C#)
- Trying to create a method to convert string letters into a two dimensional array (Java)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Conditional statements in Pascal
- Next Thread: App's with lots of strings. How?
| Thread Tools | Search this Thread |





