Xbase 1.0.4 is out. Almost all of the changes to 1.0.4 are to do with the scripting APIs. They’ve been reorganised, improved and lots of new features have been added.
Documentation for everything you see below is available here:
The Tools class has been completely restructured (full backwards-compatibility has been retained, however).
Tools.Beep() may now take an optional argument: the name of the beep sound you want to play.
//A normal beep
Tools.Beep();
//Play the "Submarine" sound
Tools.Beep("Submarine");
//Play the "Bottle" sound
Tools.Beep("Bottle");
Tools.TextAlert() is a new function that acts rather like the prompt() function in regular javascript.
var result = Tools.TextAlert("Please enter some text...", "", "I'm done.");
Log("You pressed the button called " + result.button);
Log("You typed in the text field: " + result.text);
The new Alert class gives you greater control over. It may also be expanded in the future to give you greater control over alerts.
var a = new Alert;
a.title = "This is an alert!";
a.message = "Hello James! This is an alert showcasing the new Alert class.";
a.mainButton = "My name isn't James";
a.secondaryButton = "How did you know my name?";
a.show();
Log("You pressed this button " + result.selectedButton);
Tools.ChoiceAlert() is depreciated in favour of Tools.Alert(). Tools.Alert() now has the full functionality of ChoiceAlert() but retains backwards compatibility.
The following are depreciated:
The intended replacements are:
For example:
var button = Tools.Alert("Are you sure you want to do that?", "Doing that might do something bad, make sure you've saved before doing it.", "Do it", "Don't do it","I like turtles");
if (button == Alert.MainButton)
Log("You clicked the main button!");
else
Log("You clicked another button!");
1.0.4 introduces a new class, Log
The following are depreciated:
The intended replacements are:
The following functions are new:
For example:
Log("This is a debugging message");
Print("This prints text to the console");
PrintError("This prints an error. Errors have purple backgrounds and are easily distinguishable.");
//This will return the text of the console (as a string)
var text = Log.Text;
//This will return the contents of the console (as an array of strings, one string for each session)
var contents = Log.Contents;
//This will clear everything outputted to the console this session
Log.Clear();
//This will clear every session from the console
Log.ClearAll();
You can now access controls like this:
Form[controlName]
For example:
//Old way (still valid - not depreciated)
var c1 = Form.ControlNamed("Celsius");
//New way
var c2 = Form["Celsius"];
The frames of controls (position and size) can now be changed. As before, the visbility of a control can be changed too. These changes can also be animated with animators
//Set the frame of a control
var newFrame = Form["myButton"].frame;
newFrame.size = 100;
Form["myButton"].frame = newFrame;
//Changes can also be animated
newFrame.x = 10;
Form["myButton"].animator.frame = newFrame;
//Controls can be hidden and show using the visibility property of the animator
Form["myButton"].animator.visible = false; //Hide
The following methods are depreciated:
The intended replacements are:
The following properties are new:
As with everything else, the Data class has been rearranged and made easier to use.
You can now access tables directly using the new Tables class:
var aTable = Data["Products"];
var numberOfRows = aTable.numRows;
//Or
var bTable = new Table("Products");
numberOfRows = bTable.numRows;
Log(numberOfRows);
There’s also a new Field class:
var name = Data["Products"]["Name"];
var firstName = name.value(0);
name = new Field("Products", "Name");
name.setValue(0, "iPod");
Log(firstName);
The Tools.StopScript() function halts execution of the script. Take care when using this function.
The Document.Shake() function shakes the window from left to right (emphesises that incorrect data has been entered). Use sparingly!
The Document.MarkAsNeedingChanges() marks the window’s close button with a dot. When the window is closed or Xbase quit, the user will be prompted to save changes.
Leave a Reply