How to make ? decimal HSCROLL BAR (- 10 ,,,,,,,, -0.2,-0.1,0,0.1,0.2,,,,,,,,,,,,9.9,10) in the below program (sup question) in)

How to change ranges also including negative numbers.

like this one

- 10 ,,,,,,,, -0.2,-0.1,0,0.1,0.2,,,,,,,,,,,,,,,,,,9.9,10

Thanks a lot

rtarara

-----------------------------------------------------------------------

! Modified Archery2
! A simple archery game.
! Shooting over a hill at a hidden target.
LIBRARY "TrueCtrl.trc"
OPTION ANGLE degrees
RANDOMIZE
CALL TC_Init ! Initialize for True Controls routines
CALL TC_Win_SetBrush (0, 11, -1, "") ! Set output window color
CALL TC_Show (0) ! Show the default output window
CALL TC_Win_Active (0) ! Move it to the front
LET left = -50 ! World coordinates, in feet
LET right = 200
LET bottom = -50
LET top = 100
LET g = 32.16 ! Acceleration due to gravity
SET WINDOW left, right, bottom, top
CALL TC_Show_Default (0) ! Don't automatically show things
! Create speed-setting scroll bar and related controls.
CALL TC_SText_Create (st1, "Force", -42, -20, -38, -99999)
CALL TC_SText_Create (speed0, "0", -12, -5, -38, -99999)
CALL TC_SText_Create (speed200, "200", 170, 185, -38, -99999)
CALL TC_SText_Create (speeddial, "0", -42, -20, -99999, -40)
CALL TC_SBar_Create (speedset, "HSCROLL", -12, 185, -99999, -40)
! Set the scroll bar parameters and increments.
CALL TC_Sbar_SetRange (speedset, 0, 200, 100)
CALL TC_Sbar_SetIncrements (speedset, .1, 100)
CALL TC_Sbar_SetPosition (speedset, 0)

LET currentspeed = 0
CALL MakeScene

DO ! Main event loop
! LET x1, x2 = 0
CALL TC_Event (0, event$, window, x1, x2) ! Get next event

SELECT CASE event$
CASE "LEFT", "RIGHT", "PAGELEFT", "PAGERIGHT", "HSCROLL", "END HSCROLL"
CALL TC_SBar_GetPosition (speedset, speed)
IF speed <> currentspeed then
LET currentspeed = speed/10
CALL TC_SetText (speeddial, str$(currentspeed))
print "current speed =";currentspeed
END IF
CASE ELSE
END SELECT
LOOP
PAUSE 3
CALL TC_Cleanup
STOP
! Now, the subroutines
SUB MakeScene
CLEAR
CALL ShowControls
END SUB
SUB ShowControls
CALL TC_Show (st1)
CALL TC_Show (speed0)
CALL TC_Show (speed200)
CALL TC_Show (speeddial)
CALL TC_Show (speedset)
END SUB
END

Comments

re: scroll bar negative range

If I understand what you want.....?

Setup your scroll to cover a full range of 0-200 as before (instead of 0-100), divide returned values by 10 to get your decimal values from 0-20, and then subtract 10 from the value of current speed so that the range effectively becomes -10 to +10.

*******

The TrueControl calls (like TC_Sbar_SetRange turn out to be small routines which simplify the process of using the built in Call Object() subroutine. Since we don't have the code for the Object routine, it is difficult (lack of detail in the manual) to know exactly what the limits are for the TC_Sbar parameters. I am assuming that the lower limit on Range is 0, and the increments have to be integer values. If this is the case, then the workarounds (dividing the returned value by 10 to get decimal values and subtracting a fixed value to get negative values) may be the only way to go.

rwt