how to use the slider and a database?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jpottsx1
Posts: 46
Joined: Thu Jun 04, 2009 12:46 am
Contact:

how to use the slider and a database?

Post by jpottsx1 » Sat Aug 20, 2011 5:43 pm

I want to grab the value of a "slider" and put it into a database. I have looked through the docs and find only minimal references to the "Slider" control.

Any help is greatly appreciated

Jeff
Jeff G potts

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: how to use the slider and a database?

Post by Klaus » Sat Aug 20, 2011 5:48 pm

Hi Jeff,

you are looking for "thumbposition" and "scrollbar" :D
Abbreviations (lazy me): thumbpos and sb

Getting:
...
put the thumbpos of sb "your scrollbar here" into tValueToStore
...

Setting:
...
set the thumbpos of sb "your scrollbar here" into tStoredValue
...

Best

Klaus

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: how to use the slider and a database?

Post by bangkok » Sat Aug 20, 2011 6:00 pm

jpottsx1 wrote:I want to grab the value of a "slider" and put it into a database. I have looked through the docs and find only minimal references to the "Slider" control.
a slider, with the value in a field.

Once you're able to get the value of the slider, then after it's not a problem to write it to a database.
Attachments
SB.zip
(484 Bytes) Downloaded 362 times

jpottsx1
Posts: 46
Joined: Thu Jun 04, 2009 12:46 am
Contact:

Re: how to use the slider and a database?

Post by jpottsx1 » Sat Aug 20, 2011 9:07 pm

Thanks for the direction, but I've encountered a new snag.

When I use the following code;
on scrollbardrag
put the thumbpos of sb "mysb" into pTaskName
put "INSERT into tasks (task) VALUES ('" & pTaskName & "')" into tSQL
revExecuteSQL sDatabaseID, tSQL

## Refresh the task list
showTasks
end scrollbardrag
I genererate new entries whenever I drag the mouse over the card, not just when I move the slider. Any ideas on this?

Jeff
Jeff G potts

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: how to use the slider and a database?

Post by bangkok » Sat Aug 20, 2011 9:58 pm

jpottsx1 wrote: I genererate new entries whenever I drag the mouse over the card, not just when I move the slider. Any ideas on this?
Very strange !

You put this script into the scrollbar "mysb", right ? Or in the card ? I guess you might have another scrollbar on the card ?

What about sDatabaseID, you put a "global sDatabaseID" within the script ?

jpottsx1
Posts: 46
Joined: Thu Jun 04, 2009 12:46 am
Contact:

Re: how to use the slider and a database?

Post by jpottsx1 » Sat Aug 20, 2011 10:59 pm

I had the script on the card and it was causing the problem.

I fixed the problem with putting the following code;
on mouseup
put the thumbpos of sb "mysb" into pTaskName
end mouseup

for the slider, then I put the following code in the button to create a record;
on mouseUp
put "INSERT into tasks (task) VALUES ('" & pTaskName & "')" into tSQL
revExecuteSQL sDatabaseID, tSQL

## Refresh the task list
showTasks
end mouseUp

All works fine now, thanks for the help.
Jeff G potts

Post Reply