I'm trying to modify the get commatext element script, to obtain the inverse result: remove an element from commatext.
I just want to get an element from a commatext, and remove it. The goal is to get the commatext from a list box, and being able to remove the selected element from the list.....
Any script guru who could help me?
[script) Remove element from commatext
Oups, the script:
/////////////////////////////////////////////
// Get Comma text element
////////////////////////////////////////////
// parameters declaration
var input : Tparameter;
var nth : Tparameter;
var output : Tparameter;
var sl1 : TStringList;
// destroy
procedure Destroy;
begin
sl1.free;
end;
// initialisation : create parameters
procedure init;
begin
SetModuleColor($808080+302060);
Input := CreateParam('in',ptTextField);
SetIsOutPut(Input,false);
nth := CreateParam('num',ptdataField);
SetIsOutPut(nth,false);
SetMin(nth,0);
SetMax(nth,MAXINT);
SetFormat(nth,'%.0f');
output := CreateParam('out',ptTextField);
SetIsInPut(Output,false);
Sl1 := TStringList.Create;
end;
procedure Callback(n:integer);
var idx : integer;
var result : string;
begin
Sl1.CommaText := GetStringValue(Input);
idx := round(GetValue(nth));
if (idx>=0)
and (idx<SL1.count)
then result := SL1.Strings[idx]
else result := '';
SetStringValue(Output,result);
// strace(GetStringValue(outPut));
end;
// no process bloc
Seb.Dub
I haven't tested it myself (at least not that I can remember), but after getting the input string and index I think you can try something like:
Code: Select all
Sl1.Delete(idx);
SetStringValue(Output, Sl1.CommaText);Bjørn S
Yes, thanks master bsork!
I tried delete but i have yet big difficulties with script syntax....
So, here is the good script for "Remove commatext elt":
I tried delete but i have yet big difficulties with script syntax....
So, here is the good script for "Remove commatext elt":
/////////////////////////////////////////////
// Remove Comma text element
////////////////////////////////////////////
// parameters declaration
var input : Tparameter;
var nth : Tparameter;
var output : Tparameter;
var sl1 : TStringList;
// destroy
procedure Destroy;
begin
sl1.free;
end;
// initialisation : create parameters
procedure init;
begin
SetModuleColor($808080+302060);
Input := CreateParam('in',ptTextField);
SetIsOutPut(Input,false);
nth := CreateParam('num',ptdataField);
SetIsOutPut(nth,false);
SetMin(nth,0);
SetMax(nth,MAXINT);
SetFormat(nth,'%.0f');
output := CreateParam('out',ptTextField);
SetIsInPut(Output,false);
Sl1 := TStringList.Create;
end;
procedure Callback(n:integer);
var idx : integer;
var result : string;
begin
Sl1.CommaText := GetStringValue(Input);
idx := round(GetValue(nth));
if (idx>=0)
and (idx<SL1.count)
then Sl1.Delete(idx);
SetStringValue(Output, Sl1.CommaText);
// strace(GetStringValue(outPut));
end;
// no process bloc
Seb.Dub
Sorry, but I guess could've been more spesific in telling where to place the code. I does work, though. A tip if you want the commatext sometimes to be copied in to out is to use an nth value of eg -1 and add the needed IF test.
Bjørn S
The script is ok for my need, bsork.
Thanks anyway.
Thanks anyway.
Seb.Dub
Who is online
Users browsing this forum: No registered users and 84 guests
