Slider value

This is the main technical forum for discussing problems that were encountered by users while developing PROMOTIC applications, and their possible solutions.

Slider value

Postby carnifex1992 » Fri 04. Apr 2014 9:52:09

Hi again there :)
I have another trouble - how is possible to give a slider value to variable, created in the same slider properties [using VB]
Ive tried something like this[in event page of slider]
if Slider.Value >= 0 Then
Set pMe.vars("pos")=Slider.Value
End if

, but after some time i messed up with all these object, clases, methods things :D
carnifex1992
 
Posts: 8
Joined: Sun 30. Mar 2014 20:30:28
Location: Latvia

Re: Slider value

Postby Tomáš Bräuer » Fri 04. Apr 2014 14:35:40

Hi carnifex1992!
Not sure what you mean where is your script located. You have to invoke script every time when the slider value is changed see event onDataEditAccept :
The line in your script looks odd:
Set pMe.vars("pos")=Slider.Value
probably should be
pMe.Vars("pos").Value=Slider.Value
This is valid if you have a variable Slider with reference to PmiSlider object. If Var "pos" is in the object PmiSlider the following is better:
pMe.Vars("pos").Value=pMe.Value
Keep in mind that statement Set is uset to set a reference to object set x = y. If you want to set value You use syntax: x = y

Probably the best solution for you is:
Prerequisities:
If you have somewhere a Var named by you "pos" and you have a slider and you want to have automatically write the output of slider value to your Var "pos" on change and vice versa on init you want to have slider initialised on position defined with Var "pos" (bi-directional binding)
Then:
In PmiSlider configuration page create a DBind of type GP (see http://www.promotic.eu/en/pmdoc/EditorPan/DBinds/Cfg/DBindGP.htm) for Value:
see Example 5 or 6
This way you will have your Vars("pos") bi-directionally binded with Slider.Value.
Tomáš Bräuer
Administrátor
 
Posts: 165
Joined: Thu 13. Dec 2012 9:13:13

Re: Slider value

Postby carnifex1992 » Wed 09. Apr 2014 9:16:06

Thanks for the reply, but i got still nothing :D :)

basically my problem is that i have to bind positive slider values with one variable but negative with other -

while slider value is positive i have to run motor in forward mode[1st variable], while in negative - i have to set on Bool variable[2nd variable], which starts reverse mode and after that i have to bind all negative values with the 3rd variable..but values must be as module(ABS).

Ive done already communication via mod-bus with plc and everything works fine, but here is a little trouble with this :oops:

ahh, thanks for understanding ;)
carnifex1992
 
Posts: 8
Joined: Sun 30. Mar 2014 20:30:28
Location: Latvia

Re: Slider value

Postby carnifex1992 » Wed 09. Apr 2014 11:21:54

Victory!! :D

done it like this in slider event page
If pMe.Slider.Value >= 0 Then
pMe.vars("reverse")=0
pMe.vars("frequence")=pMe.Slider.Value
ElseIf pMe.Slider.Value < 0 Then
pMe.vars("reverse")=1
pMe.vars("frequence")=Abs(pMe.Slider.Value)
End If
carnifex1992
 
Posts: 8
Joined: Sun 30. Mar 2014 20:30:28
Location: Latvia


Return to I don't know how to...

Who is online

Users browsing this forum: No registered users and 3 guests

cron