Skip to content

PositionToValue - cWebSlider

Translates the slider position into the desired database column value

Type: Function
Return Data Type: String

Parameters

Parameter Type Description
iPosition Integer Position to translate

Syntax

Function PositionToValue Integer iPosition Returns String

Call Example

Get PositionToValue iPosition to StringVariable

Description

Normally, you would bind a slider control to a numeric column value. However, you can also provide mapping functions to translate the slider position to some arbitrary value and visa-versa. This allows you to bind a column of any data type to a slider control.

Augment ValueToPosition to translate the database column value into a slider position value within the allowed range. Augment PositionToValue to translate the slider position into the desired column value.

Sample

This sample shows how to have a slider that displays font sizes but returns a slider position corresponding to font sizes.

Set pbServerOnChange to True

Procedure OnChange String sNewValue String sOldValue
    Forward Send OnChange sNewValue sOldValue

    String sVal

    Get PositionToValue sNewValue to sVal
    // do whatever with the value
End_Procedure

// called from whereever you need it (depends on your application)
Procedure SetValue string sVal
    String sOption
    Integer iPosition

    Get ValueToPosition sVal to iPosition

    WebSet piSliderValue to iPosition
End_Procedure

Function PositionToValue Integer iPosition Returns String
    If (iPosition = 1) Function_Return "0.8"
    Else If (iPosition = 2) Function_Return "0.9"
    Else If (iPosition = 3) Function_Return "1.0"
    Else If (iPosition = 4) Function_Return "1.1"
    Else If (iPosition = 5) Function_Return "1.2"
    Else If (iPosition = 6) Function_Return "1.3"
    Else If (iPosition = 7) Function_Return "1.4"
    Else If (iPosition = 8) Function_Return "1.5"
    Else If (iPosition = 9) Function_Return "1.6"
    Else If (iPosition = 10) Function_Return "1.7"
    Else If (iPosition = 11) Function_Return "1.8"
    Else If (iPosition = 12) Function_Return "1.9"
    Else If (iPosition = 13) Function_Return "2.0"
    Else If (iPosition = 14) Function_Return "2.1"
    Else If (iPosition = 15) Function_Return "2.2"
    Function_Return iPosition
End_Function

Function ValueToPosition String sValue Returns Integer
    If (sValue = "0.8") Function_Return 1
    Else If (sValue = "0.9") Function_Return 2
    Else If (sValue = "1.0") Function_Return 3
    Else If (sValue = "1.1") Function_Return 4
    Else If (sValue = "1.2") Function_Return 5
    Else If (sValue = "1.3") Function_Return 6
    Else If (sValue = "1.4") Function_Return 7
    Else If (sValue = "1.5") Function_Return 8
    Else If (sValue = "1.6") Function_Return 9
    Else If (sValue = "1.7") Function_Return 10
    Else If (sValue = "1.8") Function_Return 11
    Else If (sValue = "1.9") Function_Return 12
    Else If (sValue = "2.0") Function_Return 13
    Else If (sValue = "2.1") Function_Return 14
    Else If (sValue = "2.2") Function_Return 15
    Function_Return sValue
End_Function

Return Value

Value corresponding to slider position