' ' ' #################### ' ##### PROLOG ##### ' #################### ' PROGRAM "MyFirst" ' 1-8 char program/file name without .x or any .extent VERSION "0.0001" ' version number - increment before saving altered program ' ' You can stop the PDE from inserting the following PROLOG comment lines ' by removing them from the prolog.xxx file in your \xb\xxx directory. ' ' Programs contain: 1: PROLOG - no executable code - see below ' 2: Entry function - start execution at 1st declared func ' * = optional 3: Other functions - everything else - all other functions ' ' The PROLOG contains (in this order): ' * 1. Program name statement PROGRAM "progname" ' * 2. Version number statement VERSION "0.0000" ' * 3. Import library statements IMPORT "libName" ' * 4. Composite type definitions TYPE ... END TYPE ' 5. Internal function declarations DECLARE/INTERNAL FUNCTION Func (args) ' * 6. External function declarations EXTERNAL FUNCTION FuncName (args) ' * 7. Shared constant definitions $$ConstantName = literal or constant ' * 8. Shared variable declarations SHARED variable ' ' ****** Comment libraries in/out as needed ***** ' IMPORT "xma" ' Math library : SIN/ASIN/SINH/ASINH/LOG/EXP/SQRT... IMPORT "xcm" ' Complex library : complex number library (trig, etc) IMPORT "xst" ' Standard library : required by most programs IMPORT "xgr" ' GraphicsDesigner : required by GuiDesigner programs IMPORT "xui" ' GuiDesigner : required by GuiDesigner programs ' IMPORT "kernel32" IMPORT "user32" DECLARE FUNCTION Entry () ' ' ###################### ' ##### Entry () ##### ' ###################### ' ' Programs contain: ' 1. A PROLOG with type/function/constant declarations. ' 2. This Entry() function where execution begins. ' 3. Zero or more additional functions. ' FUNCTION Entry () DCB dcb COMMTIMEOUTS cto PcCommPort$ = "COM1" FileName$ = "C:\xb\file.txt" FileName$ = "file.txt" ' PRINT GetLastError() hFile = CreateFileA(&FileName$,ULONG($$GENERIC_READ)| ULONG($$GENERIC_WRITE), ULONG(0), 0, ULONG($$OPEN_EXISTING), 0, 0) ' PRINT hFile ' PRINT GetLastError() hCom = CreateFileA(&PcCommPort$,ULONG($$GENERIC_READ)| ULONG($$GENERIC_WRITE), 0, 0, ULONG($$OPEN_EXISTING), 0, 0) PRINT hCom GetCommState(hCom,&dcb) CloseHandle(hCom) hCom = CreateFileA(&PcCommPort$,ULONG($$GENERIC_READ)| ULONG($$GENERIC_WRITE), 0, 0, ULONG($$OPEN_EXISTING), 0, 0) ' SetCommEventMask(hCom,0) SetupComm(hCom,8192,8192) cto.ReadIntervalTimeout = 1000 cto.ReadTotalTimeoutMultiplier = 0 cto.ReadTotalTimeoutConstant = 1000 cto.WriteTotalTimeoutMultiplier = 0 cto.WriteTotalTimeoutConstant = 1000 dummy = SetCommTimeouts(hCom,&cto) PRINT "SetCommTimeouts :",dummy dcb.BaudRate = 57600 dcb.Parity = 0 dcb.StopBits = 0 dummy = SetCommState(hCom,&dcb) PRINT "SetCommState :",dummy ' PurgeComm(hCom,$$PURGE_TXCLEAR) ' PurgeComm(hCom,$$PURGE_RXCLEAR) tx1 = 0xFF tx3 = 0x0A tx2$ = "DSBS0000EC"+CHR$(10) numwritten = 0 dummy = WriteFile(hCom,&tx1,ULONG(1),&numwritten,0) dummy = WriteFile(hFile,&tx1,ULONG(1),&numwritten,0) dummy = WriteFile(hCom,&tx1,ULONG(1),&numwritten,0) dummy = WriteFile(hFile,&tx1,ULONG(1),&numwritten,0) dummy = ClearCommError(hCom,$$CE_BREAK,0) PRINT "error ", dummy dummy = WriteFile(hCom,&tx2$,ULONG(11),&numwritten,0) dummy = WriteFile(hFile,&tx2$,ULONG(11),&numwritten,0) ' dummy = WriteFile(hCom,&tx1,ULONG(1),&numwritten,0) ' dummy = WriteFile(hFile,&tx1,ULONG(1),&numwritten,0) PRINT GetLastError() PRINT "Written :",dummy PRINT "Written :",numwritten CloseHandle(hCom) CloseHandle(hFile) END FUNCTION END PROGRAM