I sometimes think that Alpha Five is easier to learn if you have not learned Alpha Four first. Although many of the general principles are similar, the actual procedures can be very different. Many Alpha Four users try to use the same procedures, which can lead to frustration ("I could do this so easily in Alpha Four, why can't I do it in Alpha Five??").
To help make the transition a little easier, this article is about one of the areas that is most dissimilar between the two programs - scripts.
As you know, in Alpha Four many of the scripts actually reproduce the keystrokes that you would make to accomplish a certain task (and the script recorder is a great way to do this). For example,
lfsav
is a simple script that will select form A (which you could have named SALES) from the current database (JOBS), and then view it. While you can easily reproduce the actions of the script by typing the keystrokes, the actual script is not particularly intuitive. Also, this script will not work as intended if you have more than one database open in your desktop, and the script is run from a different database. Therefore, a more accurate script would be:
cojobs{enter}
lfsav
In Alpha Five, the script would be:
form.view("sales")
Now, there are some important differences to mention at this point. First of all, in Alpha Four you have to make sure you're in the correct database (or set). In Alpha Five, when you create a form from a given table (remember, in Alpha Five the *.DBF is called a TABLE, not a DATABASE), you give that form a name (and make sure it is a unique name!). Therefore, the script will open the form called SALES, and the table or set to which it is attached is unimportant (from the script's point of view).
I mentioned the script recorder in Alpha Four. There is also a script recorder in Alpha Five, but this does not function the same way, mainly because scripts function differently. If you turn on the script recorder in Alpha Five, and then open the form "manually" from the Control Panel, you will see essentially the same script as shown above. If, during this time, you press some keys (to view different records, for example), you will see the result not as keystrokes, but as commands. In other words, the script recorder in A5 does not record individual keystrokes, but instead records the commands that are executed by those keystrokes. (Also, if you press a key that does nothing, nothing will show in the recorder for that keystroke).
Now, let's get into a little more scripting using variables. Once again, there are significant differences between the two programs.
For example, let's say you want to create a variable that can be used later, such as a customer ID. In Alpha Four, the syntax to define a variable and set its value is:
{set %custid, "123"}
Now, you can use this variable in other places. For example, you could design a saved search to find all records for which the field CUST_ID matches the variable's value:
CUST_ID=scripts->custid
In Alpha Five, the syntax for the script is:
dim global custid as c
custid="123"
The first line of this script sets the variable's usage (in this case, global), and also it's type (in this case, c for character). A script can have several uses, but global is the most common. This means that you can use the variable anywhere. This is the case with all variables in Alpha Four. (If you dim the variable as layout, it is ONLY effective within that layout. There are other uses, but for now we'll just deal with global variables). Also, you can define the variable as character, numeric, or date. This has some advantages over Alpha Four in that you don't have to convert the result when using a numeric or date field.
The second line of the script sets the value of the variable. Thereafter, the variable can be used in a search. For example, you could use the following syntax in the filter definition of a report, so it would only return the records in which the field CUST_ID matches the value of the variable custid:
CUST_ID=var->custid
Now, the next obvious thing to do is to have a box or window appear on the screen to prompt the user for a value for this variable. In Alpha Four, you might have a script that looks like this:
{PROMPT "Enter the Customer's ID", %custid, 3}
In Alpha Five, you could use the following:
dim global custid as c
custid=ui_get_text("CUSTOMER ID","Enter the Customer's ID")
In this case, I have shown the first line again, to keep the script complete (i.e., you only have to dim a variable once, not every time you use it). The second line defines the value of the variable as the result of a prompt that appears on the screen.

You can see how the parameters defined in the ui_get_text command affect the appearance of the prompt. (In case you're wondering, the ui part of the command simply means "user input", and is there to help make the command more intuitive).
Another fairly common use of scripts is to automate a report. This can be done in either program by designing a button to run a script. First, let's look at an Alpha Four script that will prompt the user for a customer's ID, and then display a report:
cojobs{enter}
{play "customer"}
srapra{f10}
This script plays the dialog script that prompts the user for the ID, then runs the search labeled A (which you might have named SALES PER CUSTOMER), and then prints the report labeled A. In the search, the variable %custid was used as part of the filter criteria.
In Alpha Five, the script would look like this:
dim global custid as c
custid=ui_get_text("CUSTOMER ID","Enter the Customer's ID")
query.run("sales_per_cust")
report.preview("sales_cust")
In this case, a saved query called SALES_PER_CUST (similar to a saved search in Alpha Four) has been created, and uses the variable var->custid as part of the filter criteria. Then the report called SALES_CUST is previewed.
It's worthwhile to note that, in Alpha Five, you can preview a report, and then print directly from the preview screen, which is a very nice feature! The same can be done in Alpha Four, but it takes additional scripting:
{WAITKEY} {F10} {F10}
{PROMPT "Print to Printer? ", %Y/N, 1}
{IF upper(%Y/N) = "N", {{ABORT}}, {prA (with commands to print to the printer}}
Once again, a big difference in the two programs is that Alpha Four uses letters to designate the search and report, whereas Alpha Five uses names for the query (search) and report. The letters in Alpha Four refer to a specific operation (search, report, etc.) for a specific database; therefore, that database has to be specified in the script. Alpha Five uses names instead of letters, and as long as you don't duplicate names for a given type of operation, you don't have to worry about which table that operation is attached to.
Finally, I'd like to show how to use an IF statement in both programs. First, in Alpha Four, this script evaluates %custid, and sets the variable %job accordingly:
{if %cust_id="", {{set %job, ""}}, {{set %job, "x"}}}
Now, the same script in Alpha Five:
dim global cust_id as c
dim global job as c
IF custid=""
job=""
ELSE
job="x"
END IF
Remember that I am showing the complete script, including the dim statements for the variables.
As you can see, the syntax between the two programs is quite different. Also, the Alpha Five script has more text, and therefore could seem more complicated at first. However, I think you will find that, once you get used to Alpha Five, the syntax is easier to follow.
Obviously, there are many more things that each program's scripts can do. My intent here has been to give you an idea of the fundamental syntax differences between the two programs, and to give you a starting point from which you could begin writing scripts in Alpha Five.