Class FWParameter

This class is the basic parameter that is stored for parameters that are set in the Freeway Actions by the user such as <action-text>, <action-number>, <action-checkbox>, and <action-popup> are all of this type and fwValue is a string for these. There are three subclasses of FWParameter which have other parameter types. These are Class FWLinkParameter, Class FWColorParameter and Class FWFileParameter with its own subclass Class FWImageParameter.

Properties (8)

fwAction

The action to which this parameter belongs. FWAction

fwBoolValue

The value of this parameter as a Boolean. Boolean

fwContentFile

This returns a string that is the full filename of parameters source if it has a source file. This is only possible for and . If the parameter has no file it returns the empty string. String

fwHasImages

Returns whether there are any images associated with this parameter. It returns true only if the parameter. Has images that are generated, not if it has a file associated with it. Boolean

fwName

Name of the parameter. String

fwParameters

The parameter list of which this parameter is a member.

fwType

The type of the parameter. It has the following values:

Code (ed:?? There appears to be some info missing from the original docs - weaver)

fwValue

The value that has been assigned to this parameter or set by the user. The type depends on the type of parameter (see individual parameter types eg FWlinkParameter, FWColorParameter, FWFileParameter, FWImageParameter).

Methods (3)

fwClear

This clears the current parameter.

fwFindAllImages()

This will return all the images associated with a particular parameter in an array. String

fwFindImage(imageNumber)

This returns a specific image associated with the image number parameter. If the image is sliced then there can be more than one image. The index of the image is zero-based. If there is no image at a particular index then it will return null. If the parameter is not an image parameter it will return null. String

User Methods/Properties ( 4)

fwEnable

This property allows you to control if a parameter is enabled in the interface (in the Actions palette). If Boolean you define this property as a method then Freeway will evaluate the method to return a Boolean value and use that to determine if the parameter is enabled. If you define this property as a Boolean i.e. set it to true or false then Freeway will use this value to determine if the parameter is enabled.

Example:
This example sets the fwEnable property of the parameter to be a Boolean from the value of a checkbox. Using this technique the checkbox will control if the parameter “param1” is enabled in the interface.

<item-action name="Enable Test"> 
<action-checkbox name ="enable"/> 
<action-text name ="param1"/> 

<action-javascript> 
function fwInterface() 
{ 
    var enabled = fwParameters["enable"].fwBoolValue; 
    fwParameters["param1"].fwEnable = enabled; 
} 
</action-javascript> 
</item-action> 

Example:
This example sets the fwEnable property of the parameter to be the method CalcVisibility which is then evaluated to determine if the parameter is enabled or not. Using this technique the checkbox will control if the parameter “param1” is enabled in the interface.

<item-action name="Enable Test"> 
<action-checkbox name ="enable"/> 
<action-text name ="param1"/> 

<action-javascript> 
function CalcEnable() 
{ 
    var enabled = fwParameters["enable"].fwBoolValue; 
    return enabled; 
} 
function fwInterface() 
{ 
    fwParameters["param1"].fwEnable = CalcEnable; 
} 
</action-javascript> 
</item-action> 

fwMenuItems

This property allows you to generate the items that appear in a popup menu programatically. This has the advantage that you can make menus that reflect names of items on a page or are derived from the results of executing OSA scripts. This property should either be an array or a function that returns an array.

Example 1:
This code will create a menu with the item labelled “item [0]”, “item[1]” etc.

<item-action name="Test Popup"> 
<action-popup name="Test Popup"/> 

<action-javascript> 
function fwInterface() 
{ 
    var array = new Array; 
    for (i = 0 ; i < 20 ; i++) 
    array[i]="test ["+i+"]"; 
    fwParameters["Test Popup"].fwMenuItems = array; 
} 
</action-javascript> 
</item-action> 

Example 2:
This code will create a popup menu that is based on values selected from another menu.

<page-action name="Smart Popups"> 
<action-popup name="Data Base"> 
    <value name="Customers.fp5"/> 
    <value name="Products.fp5"/> 
    <value name="Orders.fp5"/> 
</action-popup> 
<action-popup name="Fields"/> 

<action-javascript> 
function fwInterface() 
{ 
    var array = new Array; 
    var dataBase = fwParameters["Data Base"].toString(); 
    switch (dataBase) 
    { 
        default: 
        case "Customers.fp5": 
            array.push("name"); 
            array.push("address"); 
            array.push("city"); 
            array.push("state"); 
            array.push("zip"); 
            break; 
        case "Products.fp5": 
            array.push("quantity"); 
            array.push("amount"); 
            array.push("total"); 
            array.push("tax"); 
            break; 
        case "Orders.fp5": 
            array.push("product_id"); 
            array.push("price"); 
            array.push("weight"); 
            array.push("color"); 
            array.push("buy_url"); 
            break; 
    } 
    fwParameters["Fields"].fwMenuItems = array; 
}
</action-javascript>
</page-action>

Example 3:
This code will create a menu based on the selection of a file. The file is expected to be of the format:

Customers.fp5 
    name 
    address 
    city 
Products.fp5 
    product_id 
    price 
    weight 
Orders.fp5 
    quantity 

The action then parses this file and creates two menus from it

<page-action name="Smart File Popups"> 
<action-file name="DB File"> 
<value type="TEXT"> 
    </action-file> 
<action-popup name="Data Base"> 
    </action-popup> 
<action-popup name="Fields"/> 

<action-javascript> 
function BuildDataBaseMenu(file) 
{ 
    file.fwPosition=0; 
    var array = new Array; 
    // read all the lines in the file 
    while (file.fwAvailable) 
    { 
        var s=file.fwReadln(); 
        // ad it to the menu only if it contains the string 
        ".fp5" 
        if (s.indexOf(".fp5")>0) 
            array.push(s); 
    } 
    return array; 
} 
function BuildFieldMenu(file, database) 
{ 
    file.fwPosition=0; 
    var array = new Array; 
    // skip to the 'database' 
    while (true) 
    { 
        if (!file.fwAvailable) 
        return array; 
        var s=file.fwReadln(); 
        if (s==database) 
            break;
    } 
    // read it's fields 
    while (true) 
    { 
        if (!file.fwAvailable) 
            return array; 
        var s=file.fwReadln(); 
        if (s.indexOf(".fp5")>0) 
            return array; 
        array.push(s); 
    } 
    return array; 
} 
function GetMenuSelection(menu, menuArray) 
{ 
    var selection = menu.toString(); 
    if (!selection && menuArray.length) 
        return menuArray[0]; 
    for (var i in menuArray) 
    { 
        if (menuArray[i]==selection) 
            return selection; 
    } 
    if (menuArray.length) 
        return menuArray[0]; 
    return ""; 
} 
function fwInterface() 
{ 
    var theDBfile = fwParameters["DB File"]; 
    var theDatabaseMenu = fwParameters["Data Base"]; 
    var theFieldMenu = fwParameters["Fields"]; 
    if (theDBfile.fwHasFile)
    { 
        theFile = new FWFile; 
        if (theFile.fwOpenRead(theDBfile)) 
        { 
            var dataBaseMenuOptions = BuildDataBaseMenu(theFile); 
            theDatabaseMenu.fwMenuItems = dataBaseMenuOptions; 
            var dataBaseOption=GetMenuSelection(theDatabaseMenu, 
            dataBaseMenuOptions); 
            var fieldMenuOptions = BuildFieldMenu(theFile, 
            dataBaseOption); 
            theFieldMenu.fwMenuItems = fieldMenuOptions; 
            fieldMenuOptions.toString(); 
            theFile.fwClose(); 
            theDatabaseMenu.fwEnable=true; 
            theFieldMenu.fwEnable=true; 
            return; 
        } 
    } 
    theDatabaseMenu.fwEnable=false; 
    theFieldMenu.fwEnable=false; 
} 
</action-javascript> 
</page-action> 

fwTitle

This property allows you to control the title of a parameter as it appears in the actions palette. If you define this property as a method then Freeway will evaluate the method to return a string value which will be used to set the title that appears in the parameter. If you define this property as a string value then Freeway will use this value as the title. String

Example 1:
The following example will change the title of one of “param1” between on and off by setting the fwTitle property to the string “on” or “off”

<item-action name="Title Test"> 
<action-checkbox name ="on/off"/> 
<action-text name ="param1"/> 
<action-javascript> 
function fwInterface() 
{ 
    var isOn = fwParameters["on/off"].fwBoolValue; 
    if (isOn) 
        fwParameters["param1"].fwTitle = "on"; 
    else 
        fwParameters["param1"].fwTitle = "off"; 
} 
</action-javascript> 
</item-action> 

Example 2:
The following example will change the title of one of “param1” between on and off by setting the fwTitle property to the method CalcTitle.

<item-action name="Title Test"> 
<action-checkbox name ="on/off"/> 
<action-text name ="param1"/> 
<action-javascript> 
function CalcTitle() 
{ 
    var isOn = fwParameters["on/off"].fwBoolValue; 
    if (isOn) 
    return "on"; 
    else 
    return "off"; 
} 
function fwInterface() 
{ 
    fwParameters["param1"].fwTitle = CalcTitle; 
} 
</action-javascript> 
</item-action> 

fwVisible

This property allows you to control if a parameter appears in the interface (in the actions palette) or not. Boolean If you define this property as a method then Freeway will evaluate the method to return a Boolean value and use that to determine the parameter’s visibility. If you define this property as a Boolean i.e. set it to true or false then Freeway will use this value to determine if the item is visible or not.

Example:
This example sets the fwVisible property of the parameter to be a Boolean from the value of a checkbox. Using this technique the checkbox will control if the parameter “param1” is visible in the interface.

<item-action name="Visible Test"> 
<action-checkbox name ="visible"/> 
<action-text name ="param1"/> 
<action-javascript> 
function fwInterface() 
{ 
    var visible = fwParameters["visible"].fwBoolValue; 
    fwParameters["param1"].fwVisible = visible; 
} 
</action-javascript> 
</item-action> 

Example:
This example sets the fwVisible property of the parameter to be the method CalcVisibility which is then evaluated to determine if the parameter is visible or not. Using this technique the checkbox will control if the parameter “param1” is visible in the interface.

<item-action name="Visible Test"> 
<action-checkbox name ="visible"/> 
<action-text name ="param1"/> 
<action-javascript> 
function CalcVisibility() 
{ 
    var visible = fwParameters["visible"].fwBoolValue; 
    return visible; 
} 
function fwInterface() 
{ 
    fwParameters["param1"].fwVisible = CalcVisibility; 
} 
</action-javascript> 
</item-action>

Register or log in to view or add comments.

FreewayTalk

Join the friendliest community on the Net at FreewayTalk. Ask and answer questions about Softpress Freeway, or just gather around the virtual water cooler!