It's working great, except for the code that strips off the quotes. This is (with the most recent version) freezing usine. Any ideas about how better to do this (Bsork??)
The code that is trouble (commenting it out makes the script work fine) is:
Code: Select all
if (item[1] = '"') then begin
strings[i] := copy(commatext, pos - charCount + 2, charCount - 3);
end else begin
strings[i] := item;
end;Thanks,
eric
Code: Select all
/// mondoCombo by emoon//////
/// mondo combo is designed to turn a bank of switches into a combo box.
/// For the moment, we will default to pg 1 each time we start up
///
const buttonCount = 32; // 32
const itemMax = 256; // 256
var namesOUT : array of Tparameter;
var triggersIN : array of Tparameter;
var cTextIN : Tparameter;
var nextPg : Tparameter;
var prevPg : Tparameter;
var pageOUT : Tparameter;
var valueOUT : Tparameter;
var stringOUT : Tparameter;
var close : Tparameter;
var strings : array of String;
var commatext : String;
var page : integer;
var selection : integer;
var itemCount : integer;
var pageMax : integer;
// destroy
// initialisation : create parameters
procedure init;
var digit : string;
var i : integer;
begin
cTextIN := CreateParam('comma text',ptTextField);
SetIsOutput(cTextIN,false);
nextPg := CreateParam('next page',ptButton);
SetIsOutput(nextPg,false);
prevPg := CreateParam('prev page',ptButton);
SetIsOutput(prevPg,false);
stringOUT := CreateParam('text out',ptTextField);
SetIsInput(stringOUT,false);
valueOUT := CreateParam('value',ptDataField);
SetIsInput(valueOUT,false);
close := CreateParam('close',ptButton);
SetIsInput(close,false);
setArrayLength(strings, itemMax);
setArrayLength(namesOUT, buttonCount);
setArrayLength(triggersIN, buttonCount);
for i := 0 to (buttonCount - 1) do begin
digit := IntToStr(i + 1);
namesOUT[i] := CreateParam('name' + digit,ptTextField);
SetIsInput(namesOUT[i],false);
triggersIN[i] := CreateParam('button' + digit,ptButton);
SetIsOutput(triggersIN[i],false);
end;
pageOUT := CreateParam('page num',ptDataField);
SetIsInput(pageOUT,false);
page := 0;
selection := -1;
itemCount := 0;
pageMax := 0;
end;
procedure updateButtons;
var i : integer;
begin
setValue(pageOUT, page + 1);
for i := 0 to (buttonCount - 1) do begin
if ((page * buttonCount) + i) >= itemCount then begin
setStringValue(namesOUT[i], '---');
end else begin
setStringValue(namesOUT[i], strings[(page * buttonCount) + i]);
end;
end;
end;
procedure Callback(n:integer);
var charCount : integer;
var i : integer;
var item : string;
var ch: string;
var pos: integer;
begin
setValue(close, 0);
// if the user has pressed a button then set the value and close the window
for i:= 0 to buttonCount - 1 do begin
if (n = triggersIn[i]) then begin
if (page * buttonCount) + i < itemCount then begin
setValue(valueOut, i + (page * buttonCount));
setStringValue(stringOUT, strings[i + (page * buttonCount)]);
setValue(close, 1);
end;
end;
end;
// if the commaText has changed, reparse the text, and layout the buttons
if (n = cTextIN) then begin
page := 0; // reset the page number
// split the commaText
commatext := ' ' + getStringValue(cTextIN) + ',';
i := 0;
charCount := 0;
for pos := 1 to length(commatext) do
begin
ch := copy(commatext,pos,1);
if (ch = ',') then
begin
item := copy(commatext,pos - charCount + 1, charCount - 1);
//if (item[1] = '"') then begin
// can't handle quotes inside lines of text!!
//strings[i] := copy(commatext, pos - charCount + 2, charCount - 3);
// end else begin
strings[i] := item;
// end;
if (i = length(strings)) then break;
i := i + 1;
charCount := 0;
end;
charCount := charCount + 1;
end;
itemCount := i;
pageMax := trunc(itemCount/buttonCount);
updateButtons;
end;
// if the user has paged, relayout the buttons
if (n = nextPg) and (page < pageMax) then begin
page := page + 1;
updateButtons;
end else if (n = prevPg) and (page > 0) then begin
page := page - 1;
updateButtons;
end;
end;
// no process bloc