Took me a while, before i've got what you've done.
With the ordinary parameters the contents is handed over, with the OUT: switch the variable itself is handed over.
Since the variable can then be used for in- and output, like in example 2, maybe a different name for the OUT: Switch would be a good idea.
Does this also work, if i call a section in another script?
This mechanism causes that after returning from the Run (
also in a different script) eventually the parameter #? is copied into the variable %????%.
Therefore it is NOT a passing the variable by reference. That is nearly impossible in the current WB structure.
That also makes a different switch name not very sencefull.
For those who are interested, the code:
Part one before doing the Run
if AnsiPos(',OUT:', ScriptMemo.CommaText) > 0 then
begin
hasOut := true;
OutVars := TStringList.Create;
OutVars.Add('');
if hlpMemo = nil then
hlpMemo := TStringList.Create
else
hlpMemo.Clear;
hlpMemo.CommaText := AnsiUpperCase(OriginalCommand);
for i := 3 to hlpMemo.Count - 1 do
begin
if AnsiStartsStr('OUT:', hlpMemo[i]) then
OutVars.Add(AnsiReplaceText(hlpMemo[i], 'OUT:', ''))
else
OutVars.Add('');
end;
end;
Part 2 after returning from Run:
if hasOut then
begin
for i := 1 to OutVars.Count - 1 do
begin
if OutVars[i] <> '' then
begin
SetVars('Set,' + OutVars[i] + ',' + TranslateVariables('#' + IntToStr(i)));
end;
end;
OutVars.Free;
hlpMemo.Free;
hlpMemo := nil;
end;
Peter