ArrayArrayArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2010-01-20T09:58:33+02:00 https://brainmodular.fr/forums/app.php/feed/topic/1854 2010-01-20T09:58:33+02:00 2010-01-20T09:58:33+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11256#p11256 <![CDATA[[script] stripping quotes, preferred method?]]>
Well, I ended up putting in an 'open' input that resets the value of close whenever the combo is open. Not so elegant, but it works.

I will post this to addons once V5 is out....

Statistics: Posted by woodslanding — 20 Jan 2010, 08:58


]]>
2010-01-18T11:19:57+02:00 2010-01-18T11:19:57+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11239#p11239 <![CDATA[[script] stripping quotes, preferred method?]]>
I am still having a problem with this script. The automatic closing works fine the first time you use it, but doesn't work after that. So I put a manual close in, but even that has to be clicked twice to work.

It's actually almost a feature. In fact, instead of a close button, I'd like a 'keep open' switch. That makes it easy to browse a number of different selections, and still get quick combobox functionality when you need it.

But I need to figure out how to get data ins and outs working right!

Thanks as always for your AWESOME HELP!!!

I will post this in addons when I get it working right. It's a really nice alternative combobox setup for the touchscreen....

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    &#58; array of Tparameter;var triggersIN  &#58; array of Tparameter;var cTextIN     &#58; Tparameter;var nextPg      &#58; Tparameter;var prevPg      &#58; Tparameter;var pageOUT     &#58; Tparameter;var valueOUT    &#58; Tparameter;var stringOUT   &#58; Tparameter;var close       &#58; Tparameter;var stringlist&#58; TStringList;var commatext  &#58; String;var page       &#58; integer;var selection  &#58; integer;var itemCount  &#58; integer;var pageMax    &#58; integer;// destroy  --do we need to worry about destroying the stringlist??  It lasts the life of the prog, so maybe not??// initialisation &#58; create parametersprocedure init;var digit  &#58; string;var i  &#58; integer; begin        cTextIN   &#58;= CreateParam&#40;'comma text',ptTextField&#41;;    SetIsOutput&#40;cTextIN,false&#41;;    nextPg   &#58;= CreateParam&#40;'next page',ptButton&#41;;    SetIsOutput&#40;nextPg,false&#41;;    prevPg   &#58;= CreateParam&#40;'prev page',ptButton&#41;;    SetIsOutput&#40;prevPg,false&#41;;    stringOUT &#58;= CreateParam&#40;'text out',ptTextField&#41;;    SetIsInput&#40;stringOUT,false&#41;;         valueOUT &#58;= CreateParam&#40;'value',ptDataField&#41;;    SetIsInput&#40;valueOUT,false&#41;;     close &#58;= CreateParam&#40;'close',ptButton&#41;;    SetIsInput&#40;close,false&#41;;         setArrayLength&#40;namesOUT, buttonCount&#41;;      setArrayLength&#40;triggersIN, buttonCount&#41;;      for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        digit &#58;= IntToStr&#40;i + 1&#41;;        namesOUT&#91;i&#93; &#58;= CreateParam&#40;'name' + digit,ptTextField&#41;;        SetIsInput&#40;namesOUT&#91;i&#93;,false&#41;;                triggersIN&#91;i&#93; &#58;= CreateParam&#40;'button' + digit,ptButton&#41;;        SetIsOutput&#40;triggersIN&#91;i&#93;,false&#41;;    end;    pageOUT &#58;= CreateParam&#40;'page num',ptDataField&#41;;    SetIsInput&#40;pageOUT,false&#41;;        stringlist &#58;= TStringList.create;    page      &#58;=  0;    selection &#58;= -1;    itemCount &#58;=  0;    pageMax   &#58;=  0;end;procedure updateButtons;var i &#58; integer;begin    setValue&#40;pageOUT, page + 1&#41;;    for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        if &#40;&#40;page * buttonCount&#41; + i&#41; >= itemCount then begin            setStringValue&#40;namesOUT&#91;i&#93;, '---'&#41;;           end else begin                setStringValue&#40;namesOUT&#91;i&#93;, stringlist.strings&#91;&#40;page * buttonCount&#41; + i&#93;&#41;;        end;    end;end;procedure Callback&#40;n&#58;integer&#41;;var charCount &#58; integer;var i &#58; integer;var item &#58; string;var commastring&#58; string;var pos&#58; integer;begin    setValue&#40;close, 0&#41;;    // if the user has pressed a button then set the value and close the window    for i&#58;= 0 to buttonCount - 1 do begin        if &#40;n = triggersIn&#91;i&#93;&#41; then begin            if &#40;page * buttonCount&#41; + i < itemCount then begin                setValue&#40;valueOut, i + &#40;page * buttonCount&#41;&#41;;                setStringValue&#40;stringOUT, stringlist.strings&#91;i + &#40;page * buttonCount&#41;&#93;&#41;;                setValue&#40;close, 1&#41;;            end;        end;    end;    // if the commaText has changed, reparse the text, and layout the buttons    if &#40;n = cTextIN&#41; then begin        page &#58;= 0;  // reset the page number        // split the commaText        commastring &#58;= getStringValue&#40;cTextIN&#41;; //strace&#40; commastring &#41;;        stringlist.CommaText &#58;= commastring ;        itemCount &#58;= stringlist.Count - 1;                for i &#58;= 0 to itemCount do begin            item &#58;= stringlist.Strings&#91;i&#93;;//strace&#40; item &#41;;        end;        pageMax &#58;= trunc&#40;itemCount/buttonCount&#41;;        updateButtons;            end;    //  if the user has paged, relayout the buttons    if &#40;n = nextPg&#41; and &#40;page < pageMax&#41; then begin         page &#58;= page + 1;        updateButtons;    end else if &#40;n = prevPg&#41; and &#40;page > 0&#41; then begin        page &#58;= page - 1;        updateButtons;    end;       end;// no process bloc

Statistics: Posted by woodslanding — 18 Jan 2010, 10:19


]]>
2010-01-18T10:50:05+02:00 2010-01-18T10:50:05+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11235#p11235 <![CDATA[[script] stripping quotes, preferred method?]]>
on to my next problem!

Statistics: Posted by woodslanding — 18 Jan 2010, 09:50


]]>
2010-01-18T09:33:51+02:00 2010-01-18T09:33:51+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11234#p11234 <![CDATA[[script] stripping quotes, preferred method?]]>

Statistics: Posted by bsork — 18 Jan 2010, 08:33


]]>
2010-01-18T01:48:55+02:00 2010-01-18T01:48:55+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11232#p11232 <![CDATA[[script] stripping quotes, preferred method?]]>
i did some research and found the TStringList is what you need


here we go with a simple example

CODE:

//////////////////////////// TStringList example/////////////////////////// parameters declarationvar cTextIN     &#58; Tparameter;var stringlist&#58; TStringList;// initialisation &#58; create parametersprocedure init;begin      cTextIN   &#58;= CreateParam&#40;'comma text',ptTextField&#41;;    SetIsOutput&#40;cTextIN,false&#41;;    stringlist &#58;= TStringList.create;end;// Global variables// Callbackprocedure Callback&#40;n&#58;integer&#41;;var commastring &#58; string;var item &#58; string;var i &#58; integer;begin    if &#40;n = cTextIN&#41; then begin        commastring &#58;= getStringValue&#40;cTextIN&#41;;         strace&#40; commastring &#41;;        stringlist.CommaText &#58;= commastring ;        for i &#58;= 0 to stringlist.Count-1 do begin            item &#58;= stringlist.Strings&#91;i&#93;;            strace&#40; item &#41;;        end;    end;end;
as you see, it will make your life easier :)

Statistics: Posted by martignasse — 18 Jan 2010, 00:48


]]>
2010-01-18T00:03:45+02:00 2010-01-18T00:03:45+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11231#p11231 <![CDATA[[script] stripping quotes, preferred method?]]>
did you try with that ?

CODE:

AdjustLineBreaks&#40;const S&#58; string&#41;;
For the doc, if you speak about the new fast script engine, did you see this page ?

and as usine script is nearly direct delphi transcription, a google search with delphi + yourkeyword does a good job.


Hope it help

Statistics: Posted by martignasse — 17 Jan 2010, 23:03


]]>
2010-01-17T23:45:13+02:00 2010-01-17T23:45:13+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11230#p11230 <![CDATA[[script] stripping quotes, preferred method?]]>
I tried using trim(getStringValue(commatextIN)) but that does not help. Any clues how to strip a linefeed from the end of a comma text input???

Thanks,
-e

Statistics: Posted by woodslanding — 17 Jan 2010, 22:45


]]>
2010-01-17T23:23:18+02:00 2010-01-17T23:23:18+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11229#p11229 <![CDATA[[script] stripping quotes, preferred method?]]>
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:

 if &#40;item&#91;1&#93; = '"'&#41; then begin                                        strings&#91;i&#93; &#58;= copy&#40;commatext, pos - charCount + 2, charCount - 3&#41;;                end else begin                    strings&#91;i&#93; &#58;= item;                end;
This worked fine with earlier versions, but the newest usine complains. I know it's not a great solution, but it used to work! There's just not much doc on characters!!

Thanks,
eric

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    &#58; array of Tparameter;var triggersIN  &#58; array of Tparameter;var cTextIN     &#58; Tparameter;var nextPg      &#58; Tparameter;var prevPg      &#58; Tparameter;var pageOUT     &#58; Tparameter;var valueOUT    &#58; Tparameter;var stringOUT   &#58; Tparameter;var close       &#58; Tparameter;var strings    &#58; array of String;var commatext  &#58; String;var page       &#58; integer;var selection  &#58; integer;var itemCount  &#58; integer;var pageMax    &#58; integer;// destroy// initialisation &#58; create parametersprocedure init;var digit  &#58; string;var i  &#58; integer; begin        cTextIN   &#58;= CreateParam&#40;'comma text',ptTextField&#41;;    SetIsOutput&#40;cTextIN,false&#41;;    nextPg   &#58;= CreateParam&#40;'next page',ptButton&#41;;    SetIsOutput&#40;nextPg,false&#41;;    prevPg   &#58;= CreateParam&#40;'prev page',ptButton&#41;;    SetIsOutput&#40;prevPg,false&#41;;    stringOUT &#58;= CreateParam&#40;'text out',ptTextField&#41;;    SetIsInput&#40;stringOUT,false&#41;;         valueOUT &#58;= CreateParam&#40;'value',ptDataField&#41;;    SetIsInput&#40;valueOUT,false&#41;;     close &#58;= CreateParam&#40;'close',ptButton&#41;;    SetIsInput&#40;close,false&#41;;             setArrayLength&#40;strings, itemMax&#41;;    setArrayLength&#40;namesOUT, buttonCount&#41;;      setArrayLength&#40;triggersIN, buttonCount&#41;;      for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        digit &#58;= IntToStr&#40;i + 1&#41;;        namesOUT&#91;i&#93; &#58;= CreateParam&#40;'name' + digit,ptTextField&#41;;        SetIsInput&#40;namesOUT&#91;i&#93;,false&#41;;                triggersIN&#91;i&#93; &#58;= CreateParam&#40;'button' + digit,ptButton&#41;;        SetIsOutput&#40;triggersIN&#91;i&#93;,false&#41;;    end;    pageOUT &#58;= CreateParam&#40;'page num',ptDataField&#41;;    SetIsInput&#40;pageOUT,false&#41;;     page      &#58;=  0;    selection &#58;= -1;    itemCount &#58;=  0;    pageMax   &#58;=  0;end;procedure updateButtons;var i &#58; integer;begin    setValue&#40;pageOUT, page + 1&#41;;    for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        if &#40;&#40;page * buttonCount&#41; + i&#41; >= itemCount then begin            setStringValue&#40;namesOUT&#91;i&#93;, '---'&#41;;           end else begin                setStringValue&#40;namesOUT&#91;i&#93;, strings&#91;&#40;page * buttonCount&#41; + i&#93;&#41;;        end;    end;end;procedure Callback&#40;n&#58;integer&#41;;var charCount &#58; integer;var i &#58; integer;var item &#58; string;var ch&#58; string;var pos&#58; integer;begin    setValue&#40;close, 0&#41;;    // if the user has pressed a button then set the value and close the window    for i&#58;= 0 to buttonCount - 1 do begin        if &#40;n = triggersIn&#91;i&#93;&#41; then begin            if &#40;page * buttonCount&#41; + i < itemCount then begin                setValue&#40;valueOut, i + &#40;page * buttonCount&#41;&#41;;                setStringValue&#40;stringOUT, strings&#91;i + &#40;page * buttonCount&#41;&#93;&#41;;                setValue&#40;close, 1&#41;;            end;        end;    end;    // if the commaText has changed, reparse the text, and layout the buttons    if &#40;n = cTextIN&#41; then begin        page &#58;= 0;  // reset the page number        // split the commaText        commatext &#58;= ' ' + getStringValue&#40;cTextIN&#41; + ',';        i &#58;= 0;        charCount &#58;= 0;        for pos &#58;= 1 to length&#40;commatext&#41; do        begin            ch &#58;= copy&#40;commatext,pos,1&#41;;                if &#40;ch = ','&#41; then             begin                item &#58;= copy&#40;commatext,pos - charCount + 1, charCount - 1&#41;;                //if &#40;item&#91;1&#93; = '"'&#41; then begin                    // can't handle quotes inside lines of text!!                    //strings&#91;i&#93; &#58;= copy&#40;commatext, pos - charCount + 2, charCount - 3&#41;;               // end else begin                    strings&#91;i&#93; &#58;= item;              //  end;                if &#40;i = length&#40;strings&#41;&#41; then break;                 i &#58;= i + 1;                charCount &#58;= 0;                       end;            charCount &#58;= charCount + 1;                    end;        itemCount &#58;= i;        pageMax &#58;= trunc&#40;itemCount/buttonCount&#41;;        updateButtons;            end;    //  if the user has paged, relayout the buttons    if &#40;n = nextPg&#41; and &#40;page < pageMax&#41; then begin         page &#58;= page + 1;        updateButtons;    end else if &#40;n = prevPg&#41; and &#40;page > 0&#41; then begin        page &#58;= page - 1;        updateButtons;    end;        end;// no process bloc

Statistics: Posted by woodslanding — 17 Jan 2010, 22:23


]]>
BrainModular BrainModular Users Forum 2010-01-20T09:58:33+02:00 https://brainmodular.fr/forums/app.php/feed/topic/1854 2010-01-20T09:58:33+02:00 2010-01-20T09:58:33+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11256#p11256 <![CDATA[[script] stripping quotes, preferred method?]]>
Well, I ended up putting in an 'open' input that resets the value of close whenever the combo is open. Not so elegant, but it works.

I will post this to addons once V5 is out....

Statistics: Posted by woodslanding — 20 Jan 2010, 08:58


]]>
2010-01-18T11:19:57+02:00 2010-01-18T11:19:57+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11239#p11239 <![CDATA[[script] stripping quotes, preferred method?]]>
I am still having a problem with this script. The automatic closing works fine the first time you use it, but doesn't work after that. So I put a manual close in, but even that has to be clicked twice to work.

It's actually almost a feature. In fact, instead of a close button, I'd like a 'keep open' switch. That makes it easy to browse a number of different selections, and still get quick combobox functionality when you need it.

But I need to figure out how to get data ins and outs working right!

Thanks as always for your AWESOME HELP!!!

I will post this in addons when I get it working right. It's a really nice alternative combobox setup for the touchscreen....

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    &#58; array of Tparameter;var triggersIN  &#58; array of Tparameter;var cTextIN     &#58; Tparameter;var nextPg      &#58; Tparameter;var prevPg      &#58; Tparameter;var pageOUT     &#58; Tparameter;var valueOUT    &#58; Tparameter;var stringOUT   &#58; Tparameter;var close       &#58; Tparameter;var stringlist&#58; TStringList;var commatext  &#58; String;var page       &#58; integer;var selection  &#58; integer;var itemCount  &#58; integer;var pageMax    &#58; integer;// destroy  --do we need to worry about destroying the stringlist??  It lasts the life of the prog, so maybe not??// initialisation &#58; create parametersprocedure init;var digit  &#58; string;var i  &#58; integer; begin        cTextIN   &#58;= CreateParam&#40;'comma text',ptTextField&#41;;    SetIsOutput&#40;cTextIN,false&#41;;    nextPg   &#58;= CreateParam&#40;'next page',ptButton&#41;;    SetIsOutput&#40;nextPg,false&#41;;    prevPg   &#58;= CreateParam&#40;'prev page',ptButton&#41;;    SetIsOutput&#40;prevPg,false&#41;;    stringOUT &#58;= CreateParam&#40;'text out',ptTextField&#41;;    SetIsInput&#40;stringOUT,false&#41;;         valueOUT &#58;= CreateParam&#40;'value',ptDataField&#41;;    SetIsInput&#40;valueOUT,false&#41;;     close &#58;= CreateParam&#40;'close',ptButton&#41;;    SetIsInput&#40;close,false&#41;;         setArrayLength&#40;namesOUT, buttonCount&#41;;      setArrayLength&#40;triggersIN, buttonCount&#41;;      for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        digit &#58;= IntToStr&#40;i + 1&#41;;        namesOUT&#91;i&#93; &#58;= CreateParam&#40;'name' + digit,ptTextField&#41;;        SetIsInput&#40;namesOUT&#91;i&#93;,false&#41;;                triggersIN&#91;i&#93; &#58;= CreateParam&#40;'button' + digit,ptButton&#41;;        SetIsOutput&#40;triggersIN&#91;i&#93;,false&#41;;    end;    pageOUT &#58;= CreateParam&#40;'page num',ptDataField&#41;;    SetIsInput&#40;pageOUT,false&#41;;        stringlist &#58;= TStringList.create;    page      &#58;=  0;    selection &#58;= -1;    itemCount &#58;=  0;    pageMax   &#58;=  0;end;procedure updateButtons;var i &#58; integer;begin    setValue&#40;pageOUT, page + 1&#41;;    for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        if &#40;&#40;page * buttonCount&#41; + i&#41; >= itemCount then begin            setStringValue&#40;namesOUT&#91;i&#93;, '---'&#41;;           end else begin                setStringValue&#40;namesOUT&#91;i&#93;, stringlist.strings&#91;&#40;page * buttonCount&#41; + i&#93;&#41;;        end;    end;end;procedure Callback&#40;n&#58;integer&#41;;var charCount &#58; integer;var i &#58; integer;var item &#58; string;var commastring&#58; string;var pos&#58; integer;begin    setValue&#40;close, 0&#41;;    // if the user has pressed a button then set the value and close the window    for i&#58;= 0 to buttonCount - 1 do begin        if &#40;n = triggersIn&#91;i&#93;&#41; then begin            if &#40;page * buttonCount&#41; + i < itemCount then begin                setValue&#40;valueOut, i + &#40;page * buttonCount&#41;&#41;;                setStringValue&#40;stringOUT, stringlist.strings&#91;i + &#40;page * buttonCount&#41;&#93;&#41;;                setValue&#40;close, 1&#41;;            end;        end;    end;    // if the commaText has changed, reparse the text, and layout the buttons    if &#40;n = cTextIN&#41; then begin        page &#58;= 0;  // reset the page number        // split the commaText        commastring &#58;= getStringValue&#40;cTextIN&#41;; //strace&#40; commastring &#41;;        stringlist.CommaText &#58;= commastring ;        itemCount &#58;= stringlist.Count - 1;                for i &#58;= 0 to itemCount do begin            item &#58;= stringlist.Strings&#91;i&#93;;//strace&#40; item &#41;;        end;        pageMax &#58;= trunc&#40;itemCount/buttonCount&#41;;        updateButtons;            end;    //  if the user has paged, relayout the buttons    if &#40;n = nextPg&#41; and &#40;page < pageMax&#41; then begin         page &#58;= page + 1;        updateButtons;    end else if &#40;n = prevPg&#41; and &#40;page > 0&#41; then begin        page &#58;= page - 1;        updateButtons;    end;       end;// no process bloc

Statistics: Posted by woodslanding — 18 Jan 2010, 10:19


]]>
2010-01-18T10:50:05+02:00 2010-01-18T10:50:05+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11235#p11235 <![CDATA[[script] stripping quotes, preferred method?]]>
on to my next problem!

Statistics: Posted by woodslanding — 18 Jan 2010, 09:50


]]>
2010-01-18T09:33:51+02:00 2010-01-18T09:33:51+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11234#p11234 <![CDATA[[script] stripping quotes, preferred method?]]>

Statistics: Posted by bsork — 18 Jan 2010, 08:33


]]>
2010-01-18T01:48:55+02:00 2010-01-18T01:48:55+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11232#p11232 <![CDATA[[script] stripping quotes, preferred method?]]>
i did some research and found the TStringList is what you need


here we go with a simple example

CODE:

//////////////////////////// TStringList example/////////////////////////// parameters declarationvar cTextIN     &#58; Tparameter;var stringlist&#58; TStringList;// initialisation &#58; create parametersprocedure init;begin      cTextIN   &#58;= CreateParam&#40;'comma text',ptTextField&#41;;    SetIsOutput&#40;cTextIN,false&#41;;    stringlist &#58;= TStringList.create;end;// Global variables// Callbackprocedure Callback&#40;n&#58;integer&#41;;var commastring &#58; string;var item &#58; string;var i &#58; integer;begin    if &#40;n = cTextIN&#41; then begin        commastring &#58;= getStringValue&#40;cTextIN&#41;;         strace&#40; commastring &#41;;        stringlist.CommaText &#58;= commastring ;        for i &#58;= 0 to stringlist.Count-1 do begin            item &#58;= stringlist.Strings&#91;i&#93;;            strace&#40; item &#41;;        end;    end;end;
as you see, it will make your life easier :)

Statistics: Posted by martignasse — 18 Jan 2010, 00:48


]]>
2010-01-18T00:03:45+02:00 2010-01-18T00:03:45+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11231#p11231 <![CDATA[[script] stripping quotes, preferred method?]]>
did you try with that ?

CODE:

AdjustLineBreaks&#40;const S&#58; string&#41;;
For the doc, if you speak about the new fast script engine, did you see this page ?

and as usine script is nearly direct delphi transcription, a google search with delphi + yourkeyword does a good job.


Hope it help

Statistics: Posted by martignasse — 17 Jan 2010, 23:03


]]>
2010-01-17T23:45:13+02:00 2010-01-17T23:45:13+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11230#p11230 <![CDATA[[script] stripping quotes, preferred method?]]>
I tried using trim(getStringValue(commatextIN)) but that does not help. Any clues how to strip a linefeed from the end of a comma text input???

Thanks,
-e

Statistics: Posted by woodslanding — 17 Jan 2010, 22:45


]]>
2010-01-17T23:23:18+02:00 2010-01-17T23:23:18+02:00 https://brainmodular.fr/forums/viewtopic.php?t=1854&p=11229#p11229 <![CDATA[[script] stripping quotes, preferred method?]]>
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:

 if &#40;item&#91;1&#93; = '"'&#41; then begin                                        strings&#91;i&#93; &#58;= copy&#40;commatext, pos - charCount + 2, charCount - 3&#41;;                end else begin                    strings&#91;i&#93; &#58;= item;                end;
This worked fine with earlier versions, but the newest usine complains. I know it's not a great solution, but it used to work! There's just not much doc on characters!!

Thanks,
eric

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    &#58; array of Tparameter;var triggersIN  &#58; array of Tparameter;var cTextIN     &#58; Tparameter;var nextPg      &#58; Tparameter;var prevPg      &#58; Tparameter;var pageOUT     &#58; Tparameter;var valueOUT    &#58; Tparameter;var stringOUT   &#58; Tparameter;var close       &#58; Tparameter;var strings    &#58; array of String;var commatext  &#58; String;var page       &#58; integer;var selection  &#58; integer;var itemCount  &#58; integer;var pageMax    &#58; integer;// destroy// initialisation &#58; create parametersprocedure init;var digit  &#58; string;var i  &#58; integer; begin        cTextIN   &#58;= CreateParam&#40;'comma text',ptTextField&#41;;    SetIsOutput&#40;cTextIN,false&#41;;    nextPg   &#58;= CreateParam&#40;'next page',ptButton&#41;;    SetIsOutput&#40;nextPg,false&#41;;    prevPg   &#58;= CreateParam&#40;'prev page',ptButton&#41;;    SetIsOutput&#40;prevPg,false&#41;;    stringOUT &#58;= CreateParam&#40;'text out',ptTextField&#41;;    SetIsInput&#40;stringOUT,false&#41;;         valueOUT &#58;= CreateParam&#40;'value',ptDataField&#41;;    SetIsInput&#40;valueOUT,false&#41;;     close &#58;= CreateParam&#40;'close',ptButton&#41;;    SetIsInput&#40;close,false&#41;;             setArrayLength&#40;strings, itemMax&#41;;    setArrayLength&#40;namesOUT, buttonCount&#41;;      setArrayLength&#40;triggersIN, buttonCount&#41;;      for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        digit &#58;= IntToStr&#40;i + 1&#41;;        namesOUT&#91;i&#93; &#58;= CreateParam&#40;'name' + digit,ptTextField&#41;;        SetIsInput&#40;namesOUT&#91;i&#93;,false&#41;;                triggersIN&#91;i&#93; &#58;= CreateParam&#40;'button' + digit,ptButton&#41;;        SetIsOutput&#40;triggersIN&#91;i&#93;,false&#41;;    end;    pageOUT &#58;= CreateParam&#40;'page num',ptDataField&#41;;    SetIsInput&#40;pageOUT,false&#41;;     page      &#58;=  0;    selection &#58;= -1;    itemCount &#58;=  0;    pageMax   &#58;=  0;end;procedure updateButtons;var i &#58; integer;begin    setValue&#40;pageOUT, page + 1&#41;;    for i &#58;= 0 to &#40;buttonCount - 1&#41; do begin        if &#40;&#40;page * buttonCount&#41; + i&#41; >= itemCount then begin            setStringValue&#40;namesOUT&#91;i&#93;, '---'&#41;;           end else begin                setStringValue&#40;namesOUT&#91;i&#93;, strings&#91;&#40;page * buttonCount&#41; + i&#93;&#41;;        end;    end;end;procedure Callback&#40;n&#58;integer&#41;;var charCount &#58; integer;var i &#58; integer;var item &#58; string;var ch&#58; string;var pos&#58; integer;begin    setValue&#40;close, 0&#41;;    // if the user has pressed a button then set the value and close the window    for i&#58;= 0 to buttonCount - 1 do begin        if &#40;n = triggersIn&#91;i&#93;&#41; then begin            if &#40;page * buttonCount&#41; + i < itemCount then begin                setValue&#40;valueOut, i + &#40;page * buttonCount&#41;&#41;;                setStringValue&#40;stringOUT, strings&#91;i + &#40;page * buttonCount&#41;&#93;&#41;;                setValue&#40;close, 1&#41;;            end;        end;    end;    // if the commaText has changed, reparse the text, and layout the buttons    if &#40;n = cTextIN&#41; then begin        page &#58;= 0;  // reset the page number        // split the commaText        commatext &#58;= ' ' + getStringValue&#40;cTextIN&#41; + ',';        i &#58;= 0;        charCount &#58;= 0;        for pos &#58;= 1 to length&#40;commatext&#41; do        begin            ch &#58;= copy&#40;commatext,pos,1&#41;;                if &#40;ch = ','&#41; then             begin                item &#58;= copy&#40;commatext,pos - charCount + 1, charCount - 1&#41;;                //if &#40;item&#91;1&#93; = '"'&#41; then begin                    // can't handle quotes inside lines of text!!                    //strings&#91;i&#93; &#58;= copy&#40;commatext, pos - charCount + 2, charCount - 3&#41;;               // end else begin                    strings&#91;i&#93; &#58;= item;              //  end;                if &#40;i = length&#40;strings&#41;&#41; then break;                 i &#58;= i + 1;                charCount &#58;= 0;                       end;            charCount &#58;= charCount + 1;                    end;        itemCount &#58;= i;        pageMax &#58;= trunc&#40;itemCount/buttonCount&#41;;        updateButtons;            end;    //  if the user has paged, relayout the buttons    if &#40;n = nextPg&#41; and &#40;page < pageMax&#41; then begin         page &#58;= page + 1;        updateButtons;    end else if &#40;n = prevPg&#41; and &#40;page > 0&#41; then begin        page &#58;= page - 1;        updateButtons;    end;        end;// no process bloc

Statistics: Posted by woodslanding — 17 Jan 2010, 22:23


]]>