- KickAss HAL Programming -

  

 

 

 

 

Kickin' Program Design

 

HAL Scripts vs. HAL Programs

If HAL Programs are not really programs in the traditional sense, then perhaps it comes as little surprise that HAL Scripts are actually traditional computer programs.

But first we need to explain that there is no such thing as “HAL Scripts”, or even “HAL Programs” in the Automated Living Corp lexicon of HAL terms. Both terms are purely inventions of this author for the purpose of describing advanced HAL Programming techniques.

One possible action for any Rule or Macro is the “Run Program” action. This action can run any program, and can pass additional parameters to that program via the mechanism of the DOS Command line.

In our “Advanced HAL Programming Lexicon” we might be tempted to refer to this action as the “Run Script” action. It is rather doubtful that the HAL designers anticipated interfacing HAL to external scripts. This is obvious because HAL did not support passing any command line parameters to these programs until the users demanded it and this feature finally appeared only in version 2.0 of HAL. Further, other features suggest that HAL designers considered HAL a desktop centric environment. These observations strongly suggest that HAL designers only intended this action to start Windows programs on Voice Command.

With the advent of Command Line parameters, the “Run Program” action becomes an ideal tool to invoke external add-on programs for HAL.

HAL Scripts may be written in any language. However, Perl lends itself particularly well to this service. Not that there’s anything particularly magic about Perl as a language, but rather that Perl is extremely well supported and there is a ton of useful stuff available for free, and lots of help for beginning programmers.

Perl is an interpreted language. This means that the source code is all you need, there is no separate compilation step, and no need to deal with executables and other artifacts of compiled programs. Plus many compiled languages can be quite expensive to buy the development environments and there is a steep learning curve learning the tools.

Writing HAL Scripts in any other language is possible, but Perl is so very much easier. If you really want a compiled language, there are compilers for Perl as well.

So far we have talked about HAL Scripts as external programs executed by means of the HAL "Run Program" action. This is not the only way to trigger external processes.

External scripts may be invoked from Windows Scheduler based on schedules that can't be defined within HAL. This makes it easy to trigger events based on annual events, for example, which is outside the range of the HAL Scheduled Events.

Another approach is to place your external logic into a Windows DLL file. DLL's are special programs that serve as library functions for other programs. DLLs may be built with Visual C++, Delphi or similar tools. One would not normally write a DLL in Perl, because Perl is an interpreted language. In addition to using your own DLLs, it's also possible to call functions in existing DLLs. Functions in DLL files may be accessed using the External Library Action.

Vincent Buttigieg of Next Evolution offers a page with a few DLLs he has built specifically for HAL.

One last approach to running external scripts is to write a stand-alone program, in Perl or any other language, and instead of having it invoked by HAL, or a schedule, have it load and run as a service at startup. This service can periodically check HAL flags for commands based on flag state, and take whatever action is needed based on any number of possible flag states.

HAL Programs then are not really programs in the traditional sense, but rather are collections of Rules, Macros and HAL elements such as flags, timers, devices, and so on, all related to a common purpose of defining specific complex behaviors within HAL.

HAL Scripts are traditional computer programs, essentially external to HAL, but designed to complete critical functions within a HAL Program.

The HAL Script is a part of a Program, hence the apparent upside-down rendering of the terminology.

 

 

 

 

 

 

 

 

 

 

Creative Timer Usage

Timers may be loaded with a non-zero value as an Action Event. They will count down one count per second until reaching zero, when they are said to expire.

Timer as Trigger Event (TE)

When a timer expires, this event

can be used as a Trigger Event (TE) for a Rule. This is a handy way to have something occur in the future, yet retain control and delay or abort the action if conditions change.

The timer may be stopped without expiring, or reloaded with a new value.

Cont.

Navigation

Rules and Programs

Programs vs. Scripts

Scripts vs. Programs

Writing a Program

Macro Essentials

Main Menu