Script not working in the V4
Posted: 13 Jan 2020, 00:57
Edit: I pasted the code twice here, but it's not that way in the module (just checked....) I guess I'll log this as a bug...
////////////////////////////////////////////
This worked fine in V3, but not in version 4. It's supposed to scan a directory and return an item number and a name in text. The number part is still working, but the text part is broken. Just wondering what might have changed to cause this.
Thanks in advance!
-eric
////////////////////////////////////////////
This worked fine in V3, but not in version 4. It's supposed to scan a directory and return an item number and a name in text. The number part is still working, but the text part is broken. Just wondering what might have changed to cause this.
Thanks in advance!
-eric
Code: Select all
/////////////////////////////////////////////
// strip filenames
////////////////////////////////////////////
// parameters declaration
var idxIN,pathsIN,selIN : Tparameter;
var filenameOUT,displayOUT,idxOUT : Tparameter;
var pathList : TstringList;
var count : integer;
// initialisation : create parameters
procedure init;
var i : integer;
begin
SetModuleColor($807080+909960);
pathsIN := CreateParam('full paths ct',ptTextField); SetIsOutPut(pathsIN,false);
selIN := CreateParam('selection',ptDatafield); SetIsOutput(selIN,false);
idxIN := CreateParam('index',ptDatafield); SetIsOutput(idxIN,false);
filenameOUT := CreateParam('inst filename',ptTextField); SetIsInPut(filenameOUT,false);
displayOUT := CreateParam('inst name',ptTextField); SetIsInPut(displayOUT,false);
idxOUT := CreateParam('index',ptDatafield); SetIsInput(idxOUT,false);
pathList.create;
end;
procedure destroy; begin pathList.free end;
//TODO: do we need to be able to get an index out from a selection in????
procedure Callback(n:integer);
var filename,name : string;
var i,id,idx,sel : integer;
begin
if (n = pathsIN) then
begin
pathList.SetCommaText(GetStringValue(pathsIN));
count := pathList.count;
end
else if (n = selIN) then
begin
sel := trunc(getValue(selIN));
filename := SubFileExt(ExtractFileName(pathList.GetStrings(sel)));
name := copy(filename,5,length(filename) - 4);
idx := strToInt(copy(filename,1,3));
setValue(idxOUT, idx);
setStringValue(filenameOUT,filename);
setStringValue(displayOUT, name);
end
else if (n = idxIN) then
begin
id := trunc(getValue(idxIN));
setValue(idxOUT, id);
For i := 0 to count - 1 do
begin
filename := SubFileExt(ExtractFileName(pathList.GetStrings(i)));
strace('filename = ' + filename);
name := copy(filename,5,length(filename) - 4);
idx := strToInt(copy(filename,1,3));
if (id = idx) then
begin
setStringValue(filenameOUT,filename);
setStringValue(displayOUT, name);
end;
end;
// strace(GetStringValue(namesOUT));
end;
end;
// no process bloc