Once you have the ZX powered up it should be (in most cases) running the program that was installed at the factory, outputting a "Hello, world" message in a loop. You should be able to see this output using a terminal emulator (like TeraTerm or similar) configured for 19.2K baud. Alternately, you can simply fire up the ZBasic IDE, select the PC COM port to which the ZX is attached ("Serial Port Options..." on the Options menu) and observe the output in the Debug window at the bottom of the main window (click on the Debug tab if it is not showing).
Once you've confirmed that the ZX is running and outputting its message, you can move along to creating your first project. Here is an elementary "Hello, world" program in ZBasic:
Code: Select all
Sub Main()
Debug.Print "Hello, world!"
End Sub
- Launch the ZBasic IDE.
- Select "New..." from the Project menu
- In the edit box of the New Project dialog, type the name of the project, for example, hello.pjt. You may want to change the directory where the project file will be located by using the Browse... button on that dialog. Leave the checkboxes checked and click the OK button when ready to proceed.
- Note that the main source code file, hello.bas for example, is automatically created and an empty Main() subroutine is prepared in that file. Add a new second line containing the Debug.Print command from the example above.
- From the Options menu, select "Device Options..." and in the resulting dialog, select the device name corresponding to the ZX device that you have, e.g. ZX-24a. Click the OK button when ready to proceed.
- If the ZX is connected to a COM port on the PC other than COM1, you'll need to select the right COM port. Do this by selecting "Serial Port Options..." from the Options menu and then choosing the right COM port from the dropdown box labeled "Serial Port". Press OK when ready to continue.
- Compile your program by pressing the F7 key or by selecting Compile from the Project menu. In the Output window at the bottom of the IDE, you should see that the compile completed with no errors. If an error message appears, recheck the program to verify that it matches the sample above and compile it again.
- Download the compiled program the the ZX by pressing the F5 key or by selecting Go from the Project menu. If the download completes successfully, you should see the "Hello, world!" in the Debug window at the bottom of the IDE.
Code: Select all
Sub Main()
Do
Debug.Print "Hello, world!"
Call Sleep(1.0)
Loop
End Sub
A possible next step would be to add toggling of an I/O line to the loop. The code below alternately sets an I/O pin high and low, in this case a pin connected to the on-board red LED.
Code: Select all
Sub Main()
Dim state as Byte
state = 0
Do
Debug.Print "Hello, world!"
Call PutPin(Pin.RedLED, state)
If (state = 0) Then
state = 1
Else
state = 0
End If
Call Sleep(1.0)
Loop
End Sub