From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

Datatable info Via Buttons

I am using Lookout 4.5.

I have 300 buttons on my program. I want each button to reference a row of
my excel spreadsheet. I know how to set up a DataTable and I know how the
cursor member works. What I can't seem to manage (in a simple way) is.....
Button 1 moves the table cursor to Row 1
Button 2 moves the table cursor to Row 2
Button 3 moves the table cursor to Row 3
...etc.
0 Kudos
Message 1 of 11
(4,292 Views)
One obvious but not-so-clean way is to use nested IFs which I am sure has
crossed your mind:

Table1.cursor.1 = if(pb1,1,if(pb2,2,if(pb3..
and so on.

This will be one big IF statement!

The other way I can think of is using the Sequencer object. Have the Labels
of the Sequencer numbered 1 thru' 100. Then connect the buttons to the Goto
datamembers. Like,

Sequencer1.Goto1 = pb1
Sequencer1.Goto2 = pb2 ..and so on.

Now, use the Sequencer1.label as your cursor driver. i.e.,

Table1.cursor.1 = Sequencer1.label

This will do it. BUT, yep, that's the problem.. you have only 100 states
in a Sequencer. To overcome this, you can either try using multiple cursors
in your table (cursor.1, cursor.2, and so on) or use two more Sequencers.
It will be a little tricky to
use three sequencers together. I would tryt
multiple cursors. Let me know (here on the newsgroup only) how it goes and
we will probably get more ideas from other users meanwhile.

Regards,

Khalid 🙂



---------------------------
"Loren Hunt" wrote:
>I am using Lookout 4.5. I have 300 buttons on my program. I want each button
to reference a row of my excel spreadsheet. I know how to set up a DataTable
and I know how the cursor member works. What I can't seem to manage (in
a simple way) is..... Button 1 moves the table cursor to Row 1 Button
2 moves the table cursor to Row 2 Button 3 moves the table cursor to
Row 3
..etc.
0 Kudos
Message 2 of 11
(4,292 Views)
Yes - you do understand. Not only would the IF statement be huge but each
button needs to latch... then unlatch via a "cancel"... and/or unlatch via a
"done"... etc.. etc..

There would be much silly programming going that route; however, I agree
it's possible.



"Khalid Ansari" wrote in message
news:3a71ecf7@newsgroups.ni.com...
>
> One obvious but not-so-clean way is to use nested IFs which I am sure has
> crossed your mind:
>
> Table1.cursor.1 = if(pb1,1,if(pb2,2,if(pb3..
> and so on.
>
> This will be one big IF statement!
>
> The other way I can think of is using the Sequencer object. Have the
Labels
> of the Sequencer numbered 1 thru' 100. Then connect the buttons to the
Goto
> datamembers. Like,
>
> Sequencer1.Goto1 = pb1
> Sequen
cer1.Goto2 = pb2 ..and so on.
>
> Now, use the Sequencer1.label as your cursor driver. i.e.,
>
> Table1.cursor.1 = Sequencer1.label
>
> This will do it. BUT, yep, that's the problem.. you have only 100 states
> in a Sequencer. To overcome this, you can either try using multiple
cursors
> in your table (cursor.1, cursor.2, and so on) or use two more Sequencers.
> It will be a little tricky to use three sequencers together. I would
tryt
> multiple cursors. Let me know (here on the newsgroup only) how it goes
and
> we will probably get more ideas from other users meanwhile.
>
> Regards,
>
> Khalid 🙂
>
>
>
> ---------------------------
> "Loren Hunt" wrote:
> >I am using Lookout 4.5. I have 300 buttons on my program. I want each
button
> to reference a row of my excel spreadsheet. I know how to set up a
DataTable
> and I know how the cursor member works. What I can't seem to manage (in
> a simple way) is..... Button 1 moves the table cursor to Row 1
Button

> 2 moves the table cursor to Row 2 Button 3 moves the table cursor to
> Row 3
> .etc.
>
0 Kudos
Message 3 of 11
(4,292 Views)
I built in the Sequencer and it is a smashing success!

The 300 buttons categorize into 4 sub-groups. I will use 4 Sequencers to
host each of the sub-groups.

I spent 10 hours racking my brain over this problem and was resigning to the
"If" statement solution. Thank you for your help.

Cheers,
Loren

"Khalid Ansari" wrote in message
news:3a71ecf7@newsgroups.ni.com...
>
> One obvious but not-so-clean way is to use nested IFs which I am sure has
> crossed your mind:
>
> Table1.cursor.1 = if(pb1,1,if(pb2,2,if(pb3..
> and so on.
>
> This will be one big IF statement!
>
> The other way I can think of is using the Sequencer object. Have the
Labels
> of the Sequencer numbered 1 thru' 100. Then connect the buttons to the
Goto
> datamembers. Lik
e,
>
> Sequencer1.Goto1 = pb1
> Sequencer1.Goto2 = pb2 ..and so on.
>
> Now, use the Sequencer1.label as your cursor driver. i.e.,
>
> Table1.cursor.1 = Sequencer1.label
>
> This will do it. BUT, yep, that's the problem.. you have only 100 states
> in a Sequencer. To overcome this, you can either try using multiple
cursors
> in your table (cursor.1, cursor.2, and so on) or use two more Sequencers.
> It will be a little tricky to use three sequencers together. I would
tryt
> multiple cursors. Let me know (here on the newsgroup only) how it goes
and
> we will probably get more ideas from other users meanwhile.
>
> Regards,
>
> Khalid 🙂
>
>
>
> ---------------------------
> "Loren Hunt" wrote:
> >I am using Lookout 4.5. I have 300 buttons on my program. I want each
button
> to reference a row of my excel spreadsheet. I know how to set up a
DataTable
> and I know how the cursor member works. What I can't seem to manage (in
> a simple way) is..... Button 1
moves the table cursor to Row 1
Button
> 2 moves the table cursor to Row 2 Button 3 moves the table cursor to
> Row 3
> .etc.
>
0 Kudos
Message 4 of 11
(4,292 Views)
Another faster possibility than the nested if statement is
cursor=pb1*1+pb2*2+pb3*3+...
the easiest way to generate the expression is to use notepad, use the search
and replace command and paste the whole thing back into the editfield. Better
still use excel to generate the list. Takes about 2 mins
Just to show you...
pb1*1+pb2*2+pb3*3+pb4*4+pb5*5+pb6*6+pb7*7+pb8*8+pb9*9+pb10*10+pb11*11+pb12*12+pb13*13+pb14*14+pb15*15+pb16*16+pb17*17+pb18*18+pb19*19+pb20*20+pb21*21+pb22*22+pb23*23+pb24*24+pb25*25+pb26*26+pb27*27+pb28*28+pb29*29+pb30*30+pb31*31+pb32*32+pb33*33+pb34*34+pb35*35+pb36*36+pb37*37+pb38*38+pb39*39+pb40*40+pb41*41+pb42*42+pb43*43+pb44*44+pb45*45+pb46*46+pb47*47+pb48*48+pb49*49+pb50*50+pb51*51+pb52*52+pb53*53+pb54*54+pb55*55+pb56*56+pb57*57+pb58*58+pb59*59+pb60*60+pb61*61+pb62*62+pb63*63+pb64*64+pb65*65+pb66*66+pb67*67+pb68*68+pb69*69+pb70*70+pb71*71+pb72*72+pb73*73+pb74*74+pb75*75+pb76*76+pb77*77+pb78*78+pb79*79+pb80*80+pb81*81+pb82*82+pb83*83+pb84*84+pb85*85+pb86*86+pb87*87+pb88*88+pb89*89+pb90*90+pb91*91+pb92*92+pb93*93+pb94*94+pb95*95+pb96*96+pb97*97+pb98*98+pb99*99+pb100*100+pb101*101+pb102*102+pb103*103+pb104*104+pb105*105+pb106*106+pb107*107+pb108*108+pb109*109+pb110*110+pb111*111+pb112*112+pb113*113+pb114*114+pb115*115+pb116*116+pb117*117+pb118*118+pb119*119+pb120*120+pb121*121+pb122*122+pb123*123+pb124*124+pb125*125+pb126*126+pb127*127+pb128*128+pb129*129+pb130*130+pb131*131+pb132*132+pb133*133+pb134*134+pb135*135+pb136*136+pb137*137+pb138*138+pb139*139+pb140*140+pb141*141+pb142*142+pb143*143+pb144*144+pb145*145+pb146*146+pb147*147+pb148*148+pb149*149+pb150*150+pb151*151+pb152*152+pb153*153+pb154*154+pb155*155+pb156*156+pb157*157+pb158*158+pb159*159+pb160*160+pb161*161+pb162*162+pb163*163+pb164*164+pb165*165+pb166*166+pb167*167+pb168*168+pb169*169+pb170*170+pb171*171+pb172*172+pb173*173+pb174*174+pb175*175+pb176*176+pb177*177+pb178*178+pb179*179+pb180*180+pb181*181+pb182*182+pb183*183+pb184*184+pb185*185+pb186*186+pb187*187+pb188*188+pb189*189+pb190*190+pb191*191+pb192*192+pb193*193+pb194*194+pb195*195+pb196*196+pb197*197+pb198*198+pb199*199+pb200*200+pb201*201+pb202*202+pb203*203+pb204*204+pb205*205+pb206*206+pb207*207+pb208*208+pb209*209+pb210*210+pb211*211+pb212*212+pb213*213+pb214*214+pb215*215+pb216*216+pb217*217+pb218*218+pb219*219+pb220*220+pb221*221+pb222*222+pb223*223+pb224*224+pb225*225+pb226*226+pb227*227+pb228*228+pb229*229+pb230*230+pb231*231+pb232*232+pb233*233+pb234*234+pb235*235+pb236*236+pb237*237+pb238*238+pb239*239+pb240*240+pb241*241+pb242*242+pb243*243+pb244*244+pb245*245+pb246*246+pb247*247+pb248*248+pb249*249+pb250*250+pb251*251+pb252*252+pb253*253+pb254*254+pb255*255+pb256*256+pb257*257+pb258*258+pb259*259+pb260*260+pb261*261+pb262*262+pb263*263+pb264*264+pb265*265+pb266*266+pb267*267+pb268*268+pb269*269+pb270*270+pb271*271+pb272*272+pb273*273+pb274*274+pb275*275+pb276*276+pb277*277+pb278*278+pb279*279+pb280*280+pb281*281+pb282*282+pb283*283+pb284*284+pb285*285+pb286*286+pb287*287+pb288*288+pb289*289+pb290*290+pb291*291+pb292*292+pb293*293+pb294*294+pb295*295+pb296*296+pb297*297+pb298*298+pb299*299+pb300*300
0 Kudos
Message 5 of 11
(4,292 Views)
Hi Otto,

It's a good trick but won't work in this case.. 'cos once you release the
PushButton, the Expression will go back to 0.. making the cursor go back
to 1 (the first row).

So, like Loren points out, "each
button needs to latch... then unlatch via a "cancel"... and/or unlatch via
a
"done"... etc.. etc.."

By the way, do any of you use LabVIEW as well? I have written a small VI
which will generate LKS files with such repetitive connections, incrementing
the Object numbers, etc. Comes in pretty handy at times 🙂

Regards,

Khalid


-----------------------------
"otto" wrote:
Another faster possibility than the nested if statement is cursor=pb1*1+pb2*2+pb3*3+...
the easiest way to generate the expression is to use notepad, use the search
and replace command and paste the whole thing back into the editfield. Better
still use excel to generate the list. Takes about 2 mins. Just to show you...

pb1*1+pb2*2+pb3*3+pb4*4+pb5*5+pb6*6+pb7*7+pb8*8+pb9*9+pb10*10+pb11*11+pb12*12+pb13*13+pb14*14+pb15*15+pb16*16+pb17*17+pb18*18+pb19*19+pb20*20+pb21*21+pb22*22+pb23*23+pb24*24+pb25*25+pb26*26+pb27*27+pb28*28+pb29*29+pb30*30+pb31*31+pb32*32+pb33*33+pb34*34+pb35*35+pb36*36+pb37*37+pb38*38+pb39*39+pb40*40+pb41*41+pb42*42+pb43*43+pb44*44+pb45*45+pb46*46+pb47*47+pb48*48+pb49*49+pb50*50+pb51*51+pb52*52+pb53*53+pb54*54+pb55*55+pb56*56+pb57*57+pb58*58+pb59*59+pb60*60+pb61*61+pb62*62+pb63*63+pb64*64+pb65*6>5+pb66*66+pb67*67+pb68*68+pb69*69+pb70*70+pb71*71+pb72*72+pb73*73+pb74*74+pb75*75+pb76*76+pb77*77+pb78*78+pb79*79+pb80*80+pb81*81+pb82*82+pb83*83+pb84*84+pb85*85+pb86*86+pb87*87+pb88*88+pb89*89+pb90*90+pb91*91+pb92*92+pb93*93+pb94*94+pb95*95+pb96*96+pb97*97+pb98*98+pb99*99+pb100*100+pb101*101+pb102*102+pb103*103+pb104*104+pb105*105+pb106*106+pb107*107+pb108*108+pb109*109+pb110*110+pb111*111+pb112*112+pb113*113+pb114*114+pb115*115+pb116*116+pb117*117+pb118*118+pb119*119+pb120*120+pb121*121+pb122*>122+pb123*123+pb124*124+pb125*125+pb126*126+pb127*127+pb128*128+pb129*129+pb130*130+pb131*131+pb132*132+pb133*133+pb134*134+pb135*135+pb136*136+pb137*137+pb138*138+pb139*139+pb140*140+pb141*141+pb142*142+pb143*143+pb144*144+pb145*145+pb146*146+pb147*147+pb148*148+pb149*149+pb150*150+pb151*151+pb152*152+pb153*153+pb154*154+pb155*155+pb156*156+pb157*157+pb158*158+pb159*159+pb160*160+pb161*161+pb162*162+pb163*163+pb164*164+pb165*165+pb166*166+pb167*167+pb168*168+pb169*169+pb170*170+pb171*171+pb172*>172+pb173*173+pb174*174+pb175*175+pb176*176+pb177*177+pb178*178+pb179*179+pb180*180+pb181*181+pb182*182+pb183*183+pb184*184+pb185*185+pb186*186+pb187*187+pb188*188+pb189*189+pb190*190+pb191*191+pb192*192+pb193*193+pb194*194+pb195*195+pb196*196+pb197*197+pb198*198+pb199*199+pb200*200+pb201*201+pb202*202+pb203*203+pb204*204+pb205*205+pb206*206+pb207*207+pb208*208+pb209*209+pb210*210+pb211*211+pb212*212+pb213*213+pb214*214+pb215*215+pb216*216+pb217*217+pb218*218+pb219*219+pb220*220+pb221*221+pb222*>222+pb223*223+pb224*224+pb225*225+pb226*226+pb227*227+pb228*228+pb229*229+pb230*230+pb231*231+pb232*232+pb233*233+pb234*234+pb235*235+pb236*236+pb237*237+pb238*238+pb239*239+pb240*240+pb241*241+pb242*242+pb243*243+pb244*244+pb245*245+pb246*246+pb247*247+pb248*248+pb249*249+pb250*250+pb251*251+pb252*252+pb253*253+pb254*254+pb255*255+pb256*256+pb257*257+pb258*258+pb259*259+pb260*260+pb261*261+pb262*262+pb263*263+pb264*264+pb265*265+pb266*266+pb267*267+pb268*268+pb269*269+pb270*270+pb271*271+pb272*>272+pb273*273+pb274*274+pb275*275+pb276*276+pb277*277+pb278*278+pb279*279+pb280*280+pb281*281+pb282*282+pb283*283+pb284*284+pb285*285+pb286*286+pb287*287+pb288*288+pb289*289+pb290*290+pb291*291+pb292*292+pb293*293+pb294*294+pb295*295+pb296*296+pb297*297+pb298*298+pb299*299+pb300*300>
0 Kudos
Message 6 of 11
(4,292 Views)
Hey Khalid,

for that problem there are two (three) neat solutions I can offer (do i get
the NI prize for ingenuity and win the upgrade to lookout 4.5??):

1) using two expression an 1 sample object

create your Pushbuttons (say Pb1,Pb2,Pb3 to make it simple)
create an expression Exp1 : (pb1*1+Pb2*2+Pb3*3)
as suggested before
create a second expression Exp2:
(Exp1)
so exp2 just referes to exp1 no more will explain later why this is necessary
create a sample Sample1:
data: Exp1
sample: Exp2
enable:
What you will see now, is that Sample1.1
will keep the selected button number, even if you release the button.

Explanation why you need exp2:
You can not link exp1 directly into Sample1 data and sample, as exp1 will
set the sample trigger before the new
value is set in data. Therefore you
create exp2 for the trigger, which ensures that data of sample1 has already
changed. If you want to avoid exp2 then you would have to use not(exp1) as
sample trigger in sample1. This is not quiet so nice, as the cursor will
only change when you release the pushbutton.

2)
create your Pushbuttons (say Pb1,Pb2,Pb3 to make it simple)
create an expression Exp1 : (pb1*1+Pb2*2+Pb3*3)
as suggested before

This solution needs a bit of magic is a recursive if expression:
Create Exp2, property:
(exp1)
then modify the existing exp2 property to
if(exp1,exp1,exp2)
exp2 will then retain the last pb number
you have to create exp2 this way, as if you try to create the above if expression
on creating exp2, then exp2 is not yet recognized by the system as exisiting
an will therefore creat an error.

Have fun
0 Kudos
Message 7 of 11
(4,292 Views)
Hi Otto,

Well, not so fast.. these won't work in the case of... jus' kiddin 🙂

They're perfect solutions! You deserve a free upgrade.. but I am not authorised
to give you one 🙂

Khalid

------------
"otto" wrote:

Hey Khalid,

for that problem there are two (three) neat solutions I can offer (do i get
the NI prize for ingenuity and win the upgrade to lookout 4.5??):

1) using two expression an 1 sample object create your Pushbuttons (say Pb1,Pb2,Pb3
to make it simple) create an expression Exp1 : (pb1*1+Pb2*2+Pb3*3) as suggested
before create a second expression Exp2: (Exp1)
so exp2 just referes to exp1 no more will explain later why this is necessary
create a sample Sample1:
data: Exp1
sample: Exp2
enable:

What you will see now, is that Sample1.1 will keep the selected button number,
even if you release the button.

Explanation why you need exp2:
You can not link exp1 directly into Sample1 data and sample, as exp1 will
set the sample trigger before the new value is set in data. Therefore you
create exp2 for the trigger, which ensures that data of sample1 has already
changed. If you want to avoid exp2 then you would have to use not(exp1) as
sample trigger in sample1. This is not quiet so nice, as the cursor will
only change when you release the pushbutton.

2) create your Pushbuttons (say Pb1,Pb2,Pb3 to make it simple) create an
expression Exp1 : (pb1*1+Pb2*2+Pb3*3)
as suggested before

This solution needs a bit of magic is a recursive if expression:
Create Exp2, property:
(exp1)
then modify the existing exp2 property to
if(exp1,exp1,exp2)
exp2 will then retain the last pb number you have to create exp2 this way,
as if you try to create the above if expression on creating exp2, then e
xp2
is not yet recognized by the system as exisiting an will therefore creat
an error.

Have fun
0 Kudos
Message 8 of 11
(4,292 Views)
This works but don't know if it saves any coding or not.

Create a pot

Connect pot.reset to pushbutton1 or pushbutton2 or pushbutton3.....
Connect pot.resetvalue to nif(pushbutton1,1,0)+nif(pushbutton2,2,0).......

Connect table.cursor1 to nif(pushbutton1 or pushbutton2 or pushbutton3....,
pot.value, table.cursor1)

If you put the expression pushbutton1 or pushbutton2 or pushbutton3....into
an expression then you can reference this expression both for pot.reset and
table.cursor1

don't know if using a circular argument is a good thing either




"Loren Hunt" wrote:
>I am using Lookout 4.5.>>I have 300 buttons on my program. I want each
button to reference a row of>my excel spreadsheet. I know how to set up
a DataTable and I know how the>cursor membe
r works. What I can't seem to
manage (in a simple way) is.....> Button 1 moves the table cursor to Row
1> Button 2 moves the table cursor to Row 2> Button 3 moves the table
cursor to Row 3> ...etc.>>>
0 Kudos
Message 9 of 11
(4,292 Views)
What you ask is already built into the functionality of a datatable.
Connect Button 1 to data member 1.1 (this is row 1 for cursor 1)
Connect Button 2 to data member 2.1 (this is row 2 for cursor 1)
Connect Button 3 to data member 3.1 (this is row 3 for cursor 1)
Connect Button 4 to data member 4.1 (this is row 4 for cursor 1)
Connect Button 5 to data member 5.1 (this is row 5 for cursor 1)
etc.......

300 buttons is allot. I would make the first few connections using the Lookout interface and proceed with the remaining connections in the script file (.lks) using copy and paste in a text editor.

Regards,
Tommy Scharmann
Message 10 of 11
(4,292 Views)