Hardware Reference
In-Depth Information
LOCAL hPopup1 AS DWORD
portdata% = 0
current_port = &H378
' Top-level menu
MENU NEW BAR TO hMenu
' Pop-up menu for Port selection
MENU NEW POPUP TO hPopup1
MENU ADD POPUP, hMenu, "&Port", hPopup1, %MF_ENABLED
MENU ADD STRING, hPopup1, "&&H378", %ID_LPT1, %MF_CHECKED
MENU ADD STRING, hPopup1, "&&H278", %ID_LPT2, %MF_ENABLED
MENU ADD STRING, hpopup1, "&&H3BC", %ID_LPT3, %MF_ENABLED
' Pop-up menu for Help and About
MENU NEW POPUP TO hPopup1
MENU ADD POPUP, hMenu, "&Help", hPopup1, %MF_ENABLED
MENU ADD STRING, hPopup1, "&Help", %ID_HELP, %MF_ENABLED
MENU ADD STRING, hPopup1, "-", 0, 0
MENU ADD STRING, hPopup1, "&About", %ID_ABOUT, %MF_ENABLED
' Create the dialog and add controls to it
DIALOG NEW 0, "Port Test Routine", ,, 160, 84, 0, 0 TO hDlg
CONTROL ADD TEXTBOX, hDlg, %IDTEXT, "00000000", 100, 20, 48, 12, 0
CONTROL ADD BUTTON, hDlg, %IDOK, "Write to port", 14, 44, 80, 14, %BS_DEFAULT _
CALL OkButton
CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 104, 44, 40, 14, 0 _
CALL CancelButton
CONTROL ADD LABEL, hDlg, %IDLABEL, "Enter binary data to write:", 14, 20, 80, 14
MENU ATTACH hMenu, hDlg
' Display the dialog and check the returned result
DIALOG SHOW MODAL hDlg, CALL DlgProc TO lResult
IF lResult THEN
x& = VERIFY(gsUserInput, "01")
IF x& = 0 AND LEN(gsUserInput) = 8 THEN
portdata% = VAL("&B" + gsUserInput)
pbOut current_port, portdata%
MSGBOX HEX$(portdata%) & "H written to " & HEX$(current_port) & "H"
ELSE
MSGBOX "Data must comprise eight binary digits!"
END IF
END IF
END FUNCTION
'-----------------------------------------------------------
The output produced by the input32.dll PowerBASIC for Windows demon-
stration program is shown in Figure 6.11. This program contains many aspects
of good programming practice, including input verification, user help, and a
clear source code layout which includes appropriate comments.
Data files
The ability to store data acquired by a control or instrumentation system is
important where a detailed analysis of data or system performance is required.
Data may be stored in one, or more, disk files in a disk-based system. Such files
can readily be manipulated from BASIC.
The stages required for saving data in a disk file are as follows:
1
Open the file for output (using OPEN ... FOR OUTPUT ) and include a filename
or complete file specification and an associated channel number which will
be used to buffer operations on the disk file.
Search WWH ::




Custom Search