SRL Archive - OSR Help

Array of TStringArray as a function variable?


Xtensity

2011-08-03 00:16:07

How would I go about doing this?

To give you an idea of what I am trying to do..


Function SetVar(PostLink:String; Values:Array of TStringArray):Boolean;
begin

end;

So… I'm going to build this function and I have a great idea how to do it, but I'm stuck on the top part. I'm using it to post to a page with Appa… but I decided to simplify it so I could make a single function that post to a single link and only sets certain data on that link.

Sorry if that was a bad explanation.

Say I have this link..

…/Post.php

To this link, I want to change the variables on the page, I already know the variables, its only a matter of setting them.

Say I have

Say I want to set the "EMAIL" Variable to [email]JohnDoe@Gmail.com[/email]. and The PASS variable to 'opencans' or whatever haha.

I would try to put it in the function like this.

SetVar('.../Post.php',[['email','johndoe@gmail.com'],['pass','opencans']])

Though when I do this I get a type mismatch error :(. The Array Of TStringArray is set up how it should be set up… though scar doesn't seem to be able to handle it?

How would I do this? Using a Array of TStringArray in a function without a bunch of lines before I call the function which would combine all the TStringArrays… I'm trying to avoid all those extra lines. I want to be able to set all the coding up in the function so that it can do a specific task when it is called from a single line, just as a function should be.

Dgby714

2011-08-03 00:20:50

PS doesn't like arrays inside of arrays writen like that. Tho you can get past it by casting.

[TStringArray(['when', 'hehe']), TStringArray(['what', 'lol'])]

Wanted

2011-08-03 00:32:49

function AFunctionExample(var Something: T2DStringArray): Boolean;
begin
Something := [TStringArray(['when', 'hehe']), TStringArray(['what', 'lol'])];
Result := True;
end;

begin
end.

Xtensity

2011-08-03 00:33:39

Well, what's a simplier way of sending the AoTSA to the function in a single line?

And thankyou for your tips.

Wanted

2011-08-03 00:40:06

Not sure what you mean but here is another snippet

function DebugT2DSA(Something: T2DStringArray): Boolean;
var
I, II: Integer;
begin
for I := 0 to High(Something) do
for II := 0 to High(Something[I]) do
WriteLn('T2DStringArray[' + IntToStr(I) + '][' + IntToStr(II) + '] = ' + Something[I][II]);
Result := True;
end;

begin
DebugT2DSA([TStringArray(['when', 'hehe']), TStringArray(['what', 'lol'])]);
end.

Dgby714

2011-08-03 00:46:49

From: IceFire908
Not sure what you mean but here is another snippet


In Simba you can use
ToStr(T2DStringArray)