Statistics: Posted by woodslanding — 20 Jan 2010, 08:58
CODE:
/// mondoCombo by emoon///////// mondo combo is designed to turn a bank of switches into a combo box./// it breaks the elements into banks of buttons, and allows paging thru them//////const buttonCount = 32; // 32const itemMax = 256; // 256var 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 stringlist: TStringList;var commatext : String;var page : integer;var selection : integer;var itemCount : integer;var pageMax : integer;// destroy --do we need to worry about destroying the stringlist?? It lasts the life of the prog, so maybe not??// initialisation : create parametersprocedure 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(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); stringlist := TStringList.create; 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], stringlist.strings[(page * buttonCount) + i]); end; end;end;procedure Callback(n:integer);var charCount : integer;var i : integer;var item : string;var commastring: 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, stringlist.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 commastring := getStringValue(cTextIN); //strace( commastring ); stringlist.CommaText := commastring ; itemCount := stringlist.Count - 1; for i := 0 to itemCount do begin item := stringlist.Strings[i];//strace( item ); end; 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 blocStatistics: Posted by woodslanding — 18 Jan 2010, 10:19
Statistics: Posted by woodslanding — 18 Jan 2010, 09:50
Statistics: Posted by bsork — 18 Jan 2010, 08:33
CODE:
//////////////////////////// TStringList example/////////////////////////// parameters declarationvar cTextIN : Tparameter;var stringlist: TStringList;// initialisation : create parametersprocedure init;begin cTextIN := CreateParam('comma text',ptTextField); SetIsOutput(cTextIN,false); stringlist := TStringList.create;end;// Global variables// Callbackprocedure Callback(n:integer);var commastring : string;var item : string;var i : integer;begin if (n = cTextIN) then begin commastring := getStringValue(cTextIN); strace( commastring ); stringlist.CommaText := commastring ; for i := 0 to stringlist.Count-1 do begin item := stringlist.Strings[i]; strace( item ); end; end;end;Statistics: Posted by martignasse — 18 Jan 2010, 00:48
CODE:
AdjustLineBreaks(const S: string);Statistics: Posted by martignasse — 17 Jan 2010, 23:03
Statistics: Posted by woodslanding — 17 Jan 2010, 22:45
CODE:
if (item[1] = '"') then begin strings[i] := copy(commatext, pos - charCount + 2, charCount - 3); end else begin strings[i] := item; end;CODE:
/// 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; // 32const itemMax = 256; // 256var 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 parametersprocedure 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 blocStatistics: Posted by woodslanding — 17 Jan 2010, 22:23
Statistics: Posted by woodslanding — 20 Jan 2010, 08:58
CODE:
/// mondoCombo by emoon///////// mondo combo is designed to turn a bank of switches into a combo box./// it breaks the elements into banks of buttons, and allows paging thru them//////const buttonCount = 32; // 32const itemMax = 256; // 256var 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 stringlist: TStringList;var commatext : String;var page : integer;var selection : integer;var itemCount : integer;var pageMax : integer;// destroy --do we need to worry about destroying the stringlist?? It lasts the life of the prog, so maybe not??// initialisation : create parametersprocedure 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(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); stringlist := TStringList.create; 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], stringlist.strings[(page * buttonCount) + i]); end; end;end;procedure Callback(n:integer);var charCount : integer;var i : integer;var item : string;var commastring: 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, stringlist.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 commastring := getStringValue(cTextIN); //strace( commastring ); stringlist.CommaText := commastring ; itemCount := stringlist.Count - 1; for i := 0 to itemCount do begin item := stringlist.Strings[i];//strace( item ); end; 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 blocStatistics: Posted by woodslanding — 18 Jan 2010, 10:19
Statistics: Posted by woodslanding — 18 Jan 2010, 09:50
Statistics: Posted by bsork — 18 Jan 2010, 08:33
CODE:
//////////////////////////// TStringList example/////////////////////////// parameters declarationvar cTextIN : Tparameter;var stringlist: TStringList;// initialisation : create parametersprocedure init;begin cTextIN := CreateParam('comma text',ptTextField); SetIsOutput(cTextIN,false); stringlist := TStringList.create;end;// Global variables// Callbackprocedure Callback(n:integer);var commastring : string;var item : string;var i : integer;begin if (n = cTextIN) then begin commastring := getStringValue(cTextIN); strace( commastring ); stringlist.CommaText := commastring ; for i := 0 to stringlist.Count-1 do begin item := stringlist.Strings[i]; strace( item ); end; end;end;Statistics: Posted by martignasse — 18 Jan 2010, 00:48
CODE:
AdjustLineBreaks(const S: string);Statistics: Posted by martignasse — 17 Jan 2010, 23:03
Statistics: Posted by woodslanding — 17 Jan 2010, 22:45
CODE:
if (item[1] = '"') then begin strings[i] := copy(commatext, pos - charCount + 2, charCount - 3); end else begin strings[i] := item; end;CODE:
/// 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; // 32const itemMax = 256; // 256var 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 parametersprocedure 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 blocStatistics: Posted by woodslanding — 17 Jan 2010, 22:23