;************************************************************* ;*A program for reading data from a serial port into ;*paradox for Windows. ;* ;*Be sure to put a copy of the three libraries below in ;*your paradox directory so that the script can find them. ;* ;*Begin of Uses window: ;************************************************************* Uses CDRVHF ;.DLL(.LIB) CdrvSetTimerResolution(port CWORD, resolution CWORD) CWORD SetPortCharacteristics(port CWORD, baud CWORD, parity CWORD, length CWORD, stopbit CWORD, protocol CWORD) CWORD InitializePort(port CWORD, subport CWORD, addr CWORD, irq CWORD, cardtype CWORD, cardseg CWORD, inbuflen CWORD, outbuflen CWORD, flag CWORD) CWORD SetTimeout(port CWORD, timeval CWORD) CWORD GetString(port CWORD, len CWORD, str CPTR) CWORD UnInitializePort(port CWORD) CWORD endUses ;I include the other two libraries just in case Uses CDRVDLL endUses ;.DLL (.LIB) Uses CDRVXF endUses ;.DLL(.LIB) ;begin of main window method run(var eventInfo Event) ;constant and variable values tailored to our particular port, ;should be modified to fit serial board, port, etc. const port = 0 baud = 7 ;9600 baud parity = 2 ;even length = 2 ;7 bits stopbit = 1 ;2 stopbits protocol = 0 ;RTSRTS beepType = 0 textType = 16 ;constants for setting the timer resolution = 0 ;each increment is 1/18 sec timeval = 360 ;360 increments equals 20 sec ;constants for initializing the port subport = 0 addr = 256 ;note that this is decimal not hex irq = 4 cardtype = 0 ; CARD_BOCA1610 which we are using ;is normal, use CARD_WINAPI if using built-in driver cardseg = -1 ;"ffff" inbuflen = 128 outbuflen =32 flag = 0 ;constants for getting string input len = 14 endConst var text, caption, caption2, ch String stat, pcb SmallInt endVar ch = space(len) text = "Error in CDRV function" caption = "Function error" caption2 = "FYI" msgInfo(caption2, "Ready to read barcode") ;Trial passage with communications calls: ;SetPortChars, Initialize, and then uninitialize stat=InitializePort(port,subport,addr,irq,cardtype,cardseg,inbuflen,outbuflen,flag) if(stat > 0) then msgInfo(caption,"Couldn't initialize port, error: " + String(stat)) endif stat=SetPortCharacteristics(port,baud,parity,length,stopbit,protocol) if (stat > 0) then msgInfo(caption, "Couldn't set port chars, error: " + String(stat)) endif stat=CdrvSetTimerResolution(port,resolution) if (stat = -1) then msgInfo(caption, text) endif stat=SetTimeout(port,timeval) if (stat = -1) then msgInfo(caption, text) endif msgInfo( "FYI", "Opened port no." + String(port)) ;after OK click, script will wait for up to 20 sec ;for a string to arrive in the port if (GetString(port,len,ch) > 0) then msgInfo( caption2, "String read is " + ch) else msgInfo(caption, text) endif stat=UnInitializePort(port) endmethod