Last updated: 16 September 2006 |
Subject: DateAndTime(Pocket PC) Sent: Saturday, September 16, 2006 05:57:36 From: John Farrant (johnfarrant@gmail.com) I thought you might be interested in the following NSBasic code which sends the date and time to ETX's (non premier models) from a pocketpc. It is a adaption of one of NSBasic's sample programs. It works quite happily on Pocketpc's which have a proper RS232 port. My IPAQ RZ1710 has such a port and I believe other IPAQs are the same. Different pocketpc models may need a special adapter. A copy of NSBASIC is needed of course to compile the code but it really is worth the effort as it works a dream. Sorry, I forgot. Congratulations on your tenth anniversary. Regards, John Farrant Option Explicit Rem SerialComms - Send Date and Time to Autostar 'John Farrant ShowOKButton True 'Set minimize button to close app Dim selection,myString On Error resume next AddObject "Comm" If err Then MsgBox "Comm control not installed. Please check the ReadMe file's section on ""Install Device Components"" for more information.",,"SerialComms" Bye End If On Error Goto 0 selection=0 myString="" AddObject "commandButton","Write",35,65,170,20 write.text="Send Date and Time" AddObject "commandButton","Quit",35,105,170,20 Quit.text="Exit" Sub Close_Click() Comm.PortOpen = 0 killfocus End Sub Sub form_close() Comm.PortOpen = 0 End Sub Sub Comm_OnComm() Dim InString Select Case Comm.CommEvent Case 2 ' character In - collect until return is received InString = Comm.Input If Asc(InString)=13 Then MsgBox myString myString="" Else myString=myString & InString End If Case Else MsgBox "Other CommEvent Received:" & comm.commEvent End Select End Sub Sub Write_Click() Dim myString,when,myday,mymonth,myyear,mysec,mymin,myhour Comm.Rthreshold = 1 'event on every character in Comm.InputMode = 0 'text mode Comm.Settings="9600,N,8,1" Comm.handshaking=0 '0=none, 1=XON/XOFF, 2=HW Comm.RTSEnable=True comm.DTREnable=True Comm.PortOpen = True If err<>0 Then MsgBox "Open Comm: " & err.description err.clear End If When = Now myday=CStr(Day(when)) mymonth=CStr(Month(when)) myyear=CStr(Year(when)) mysec=CStr(Second(when)) mymin=CStr(Minute(when)) myhour=CStr(Hour(when)) myyear=Right(myyear,2) If Len(mysec)<2 Then mysec="0"+mysec End If If Len(mymin)<2 Then mymin="0"+mymin End If If Len(myhour)<2 Then myhour="0"+myhour End If If Len(myday)<2 Then myday="0"+myday End If If Len(mymonth)<2 Then mymonth="0"+mymonth End If Print "" Print "" Print"" Print"" Print"" Print"" Print"" Print"" Print"" Print"" Print"" Print"" Print"" Print " #:SC "&mymonth&"/"&myday&"/"&myyear&"#" Print " #:SL "&myhour&":"&mymin&":"&mysec&"#" myString = "#:SC "&mymonth&"/"&myday&"/"&myyear&"#" Comm.Output = myString myString = "#:SL "&myhour&":"&mymin&":"&mysec&"#" Comm.Output = myString sleep(5000) Comm.PortOpen = 0 killfocus End Sub Sub Quit_Click() Bye killfocus End Sub
Go back to the Autostar Information page.
Go back to the ETX Home Page.