Can I create a script that runs when my application starts up and when the user has signed on?

Yes. See Application Level Basic Properties. Refer to the onApplicationStart, onApplicationEnd, onSignOn and onSignOff properties.

Can I create a script that runs when a particular screen arrives?

Yes. See axScreenBasicProperties - Screen Level Basic Properties. Refer to the onArrive and onLeave properties.

How can I hide AXES menu bar and status bar?

SHOWAXESMENUBAR and SHOWAXESSTATUSBAR functions control the visibility of menu & status bar. If you want to always hide the menu / status in your application, put the following code in the onApplicationStart event of your application.

SHOWAXESMENUBAR(false); // false = hide, true = show

SHOWAXESSTATUSBAR(false);

My script needs to change a property of an element’s eXtension at runtime. Can it do that?

Yes, using the setProperty method of the element.

For example, a script under a certain condition needs to hide another element named "AdditionalDetails". We can do this by setting the visible property of the element to false (visible property can be found in the property sheet under Basic Properties).

Image

The script would look something like this:

// get a reference to the AdditionalDetails element

var F = FIELDS("AdditionalDetails");

// change the visible property to false

F.setProperty("visible", false);

// very important, must call refresh for property changes to take effect

F.refresh();

Note the last line – you need to call the refresh method of the element after changing a property of an element in order for the changes to be reflected visually.

Note how this is different from changing the current value of an element (remember that every element has a text value) using the setValue method – call to refresh is not required after setValue.

To get a property value, use the getProperty method.

Example:

If you wanted to show/hide according to its current state – if visible à hide otherwise show:

var F = FIELDS("AdditionalDetails");

var bVisible = F.getProperty("visible");

if (bVisible) {

F.setProperty("visible", false);

} else {

F.setProperty("visible", true);

}

F.refresh();

Note: you could write the above in only 3 lines of code:

var F = FIELDS("AdditionalDetails");

F.setProperty("visible",!(F.getProperty("visible")))

F.refresh();

For more detailed information about getProperty and setProperty methods refer to the Scripting Reference.

Can I stop the user pressing a function key?

Yes. Try this example as the onLeave script in a customized screen:

if (ENV.key == "F1") { var bOK = window.confirm("Press OK to send F1=Help request. Click Cancel to stop it."); if (!bOK) ENV.returnValue = false; }

When F1 is used this script confirms the usage - selectively cancelling it by setting ENV.returnValue = false;

Administrators

Legal Mentions

aXes is brought to you by:

LANSA

Serving the IBM i community for 30 years.