Web_Scripting

Instructs WEB emulation to execute the scripting information. The code should start with a javascript: or vbscript: string to ensure that the correct scripting type is used.

Parameters

Code

The JavaScript or VBScript that the Web emulator will execute.

Format

Web_Scripting ("Code")

Return Value

Returns a Boolean. TRUE if the script execution started successfully, returns FALSE otherwise.

Example

This example has two parts: the Wavelink script and HTML with embedded JavaScript. The following Wavelink script annunciates the item prompt and number. It also prompts for a quantity to be picked. The script then waits for a quantity to be stated. This quantity is passed back to the JavaScript.

Script( dnwebdemo )

String( strMessage2 )

String( strPickQty )

String( strItemPrompt2 )

String( strItem2 )

String( strCmdLn )

String( sSpeechResult )

Boolean( bSpeechStarted )

Boolean( bSpeechDone )

Number( nReadMode )

Comment: Enable Speakeasy Support

If_Not( Speech_To_Text_Available )

Ask_OK( "Speech-to-Text is not available.", "Error" )

Return

End_If

If_Not( Speech_From_Text_Available )

Ask_OK( "Text-to-Speech is not available.", "Error" )

Return

End_If

Speech_To_Text_Cancel

Speech_Change_Setting( "stt_language", Speech_Find_Setting_Value( "stt_language", "enu", FALSE ) )

Speech_Change_Setting( "tts_language", Speech_Find_Setting_Value( "tts_language", "English", FALSE ) )

Comment: Ensure read mode is in sentence mode

nReadMode = Speech_Find_Setting_Value( "tts_readmode", "sentence", FALSE )

Speech_Change_Setting( "tts_readmode", nReadMode )

Comment: Annunciate Item prompt

Speech_From_Text( strItemPrompt2, TRUE )

Comment: Change read mode to character mode to annunciate part number

nReadMode = Speech_Find_Setting_Value( "tts_readmode", "character", FALSE )

Speech_Change_Setting( "tts_readmode", nReadMode )

Comment: Annunciate Item number

Speech_From_Text( strItem2, TRUE )

Comment: Change read mode back to sentence mode to annunciate task

nReadMode = Speech_Find_Setting_Value( "tts_readmode", "sentence", FALSE )

Speech_Change_Setting( "tts_readmode", nReadMode )

Comment: Annunciate task to perform

Speech_From_Text( strMessage2, TRUE )

Comment: Acquire pick quantity via speech-to-text

Comment: Initialize Speech-To-Text variables

bSpeechStarted = FALSE

bSpeechDone = FALSE

sSpeechResult = ""

Comment: Speech-To-Text Loop used to acquire Speech-To-Text

While( TRUE )

Comment: Start Speech-To-Text if not already started

Comment: This is needed so we start Speech_To_Text again if
Comment: nothing was stated before it times out.

If_Not( bSpeechStarted )

Comment: With this Speech-To-Text function, the script
Comment: continues script process while waiting for speech.

bSpeechStarted = Speech_To_Text_No_Wait( bSpeechDone, sSpeechResult, "four_digits.bnf" )

End_If

If( bSpeechDone )

Comment: If sSpeechResult is not empty it signifies that we
Comment: received a speech result.

Comment: The While loop is exited when we get a speech result.

If_Not( String_Empty( sSpeechResult ) )

Break

End_If

Comment: Re-Initialize Speech engine if nothing was stated

bSpeechStarted = FALSE

bSpeechDone = FALSE

sSpeechResult = ""

Continue

End_If

Comment: Wait_For_Screen_Update waits for speech as well.

Wait_For_Screen_Update

End_While

Comment: Assign strPickQty to Speech-To-Text Result

strPickQty = sSpeechResult

Comment: Web_Scripting( "javascript:alert('sSpeechResult')" )

strCmdLn = String_Combine( "javascript:ModifyField('", strPickQty )

strCmdLn = String_Combine( strCmdLn, "');" )

Web_Scripting( strCmdLn )

Return

The HTML sample with embedded JavaScript uses a meta tag to call an OnLoad function. This function in turn calls the wls:dnwebdemo (Wavelink script). This script displays a prompt with an item number. It also shows an entry field where a quantity can be entered manually or through Speech-To-Text.

<html>

<head>

<Title> Simple Speakeasy WIB Demo </Title>

<!--Meta Tag used to launch OnLoad function within Wavelink Industrial Browser.-->

<META http-equiv=OnStartup content=Javascript:OnLoad();>

</head>

<script type = "text/javascript">

//Prompt at the top of the web page.

document.write("Item Number is 15469.");

// Variables used for Text-To-Speech annunciation. These values are
// passed to the Wavelink Industrial Browser script for processing.

var strItemPrompt = "Item Number is ";

var strItem = 15469;

</script>

<!--The pickqty entry field is defined in this form.-->

<form name="form1">

<input type = "text" name="entryfield" size="20" id="pickqty" value="">

</form>

<script type = "text/javascript">

//This message is passed to the Wavelink script so that it can be
//annunciated via Text-To-Speech.

var strMessage = "Enter quantity of items to be picked!";

//This sets the default value of the pickqty field.

var strPickQty = document.getElementById("pickqty");

strPickQty.value = "Enter quantity here.";

function ModifyField(strPickQty)

{

//Use this function to change the value of the pickqty field via Speech-
//To-Text from Wavelink Industrial Browser.

document.getElementById("pickqty").value = strPickQty;

}

//With the use of the Meta Tag defined in the Head tag above, the
OnLoad() //function is called.

function OnLoad()

{

// The variable request is set to the call of the Wavelink script. Note
// the wls prefix.

var request = "wls:dnwebdemo(strMessage2="+strMessage+",strItemPrompt2="+strItemPrompt+",strItem2="+strItem+")";

// The Wavelink script is called as a hyperlink. Wavelink Industrial
// Browser is required for this call to be understood.

window.location.href = request;

}

</script>

<body>

</body>

</html>

See Also

Web_Navigate, Web_Navigate_Frame, Web_Navigate_Post_Data, Web_Search_Source, Web_Get_Current_Element, Web_Get_Source, String_Set

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal