Database driven scripts

Posted 24 October, 2008 in Other Stuff

I am currently working on a Scala InfoChannel project where the entire script needs to be database driven so clients can log into an online portal, and change the order of screens without the need for any technical knowledge.

This is done by the Scala script talking to a VBScript that in turn gets the data for the current page. 

The trick is the use of the  OnNotification function. Using this function you can tell the Scala script to jump to a certain location when a variable has changed.

Take the following OnNotification function and stick it into the first “Group:” before the “Sequence:” begins. Then set “VARIABLE” to anything you want. “VARIABLE” is then shared with a VBScript. When ever the VBScript changes “VARIABLE”, the OnNotification function send the script to “HandleAction”.

OnNotification("VARIABLE", Use("HandleAction"));

Then put the following :”HandleAction” event within the first Group Sequence. Perhaps at the bottom of the script.

The following example shows how if “VARIABLE” is the name of an Event, it will be sent to this event.

:"HandleAction"
  {
  Sequence:
  GotoExpr(VARIABLE, Bookmark(bookmark));
  }

For more on Scala Infochannel database driven scripts see: 

http://www.futtock.co.uk/category/scala-infochannel/

Connect to MSSQL database

Posted 21 October, 2008 in Other Stuff

The following code can be used in VBScript to connect to a database. It uses both a timout and ping to make sure there is a connection to the database.

This is very handy when creating database driven Scala Infochannel scripts. It also uses error traping to make sure the script does not stop running when no connection was made so that you can use an alternative source of data such as text files.

' These are the database connection details. Change the IP address, Username and Password.
DBdetails = "Driver=SQL Server; Server=IPADDRESS; Database=sms; Uid=USERNAME; Pwd=PASSWORD"

' This is the IP address again
DBipaddress = "IPADDRESS"

On Error Resume Next ' Enable error handling

' Try to ping the database
 Set WshShell = CreateObject("WScript.Shell")
 PINGFlag = Not CBool(WshShell.run("ping -n 1 " & DBipaddress,0,True))
 If PINGFlag = True Then
  ' Connect to the db
  Set myConnection = CreateObject("ADODB.Connection")
  myConnection.ConnectionTimeout = 5
  myConnection.Open DBdetails
 Else
  Err.Number = 1
 End If

If Err.Number <> 0 Then ' There was an error when connecting to the DB.

Else

 ' Code goes here if database was contacted

End If

Change Cursor Colour

Posted 21 October, 2008 in Other Stuff

When using input text boxes in Scala InfoChannel Designer, the default colour for the cursor seems to be yellow. There does not seem to be an obvious way to set this colour. The way around this is to change the yellow in the pallet to what ever colour you want or go straight to the source code and chagne the pen(11) value to one of the other colours such as Pen(1) for black.

Offline database driven scripts

Posted 21 October, 2008 in Other Stuff

Running a database driven scala script is great but what do you do if the connection to the database goes down?

The solution is to not have a database driven script!

Seriously though, make the script text file driven, so that all the data required by the script comes from a text file. Then have a VBScript (or what ever windows script you use) update the text file.

You can have the Scala script run the “updater” VBScript, but remember to have Wait turned off, otherwise the scala script will stop everytime it ries to update the text file.

Scala InfoChannel Get Player Name

Posted 21 October, 2008 in Other Stuff

In Scala InfoChannel if you want to get the name of the player there are two ways to do this:

1. 

The variable Billing.PlayerName will return it.

Ex: playername = Billing.PlayerName;

2.

If using VBScript the following will get the player name

Set WshNetwork = CreateObject(“WScript.Network”)
playername = WshNetwork.ComputerName