JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 I implemented this in; not sure if I plugged in values correctly, but its not writing to the console for me. $Start = $Longitude and $Latitude $Current = $start For $I = 1 to 1000 $Current = $I If $Current <> $Start Then ConsoleWrite("My current position is " $Current & @CR "I have moved " & $Current - $Start & " miles from the beginning" & @CR) EndIf Next Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 13, 2012 Share Posted September 13, 2012 (edited) You're missing an ampersand (&) after the first @CR.edit: And before $Current. Edited September 13, 2012 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 13, 2012 Share Posted September 13, 2012 What is this line $Start = $Longitude and $Latitude supposed to be doing? Because the result of that will be that $start will equal 0 or 1 depending upon what's in the other 2 variables. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 Thank you somdcomputerguy Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 I changed it to 0 that was my mistake Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 (edited) I'm recieving an error:For $I = $Latitude and $LongitudeFor $I = $Latitude and $Longitude^ ERRORam I missing a carriage return or something elscI changed and to ToThis ran; but I need to pause the start time; and let the $Current-$Start change.$Start = 0 $Current = $Start For $I = $Latitude To $Longitude $Current = $I If $Current <> $Start Then ConsoleWrite("My current position is " & $Current & @CR & "I have moved " & $Current - $Start & " miles from the beginning" & @CR) EndIf Next Edited September 13, 2012 by JonBMN Link to comment Share on other sites More sharing options...
jdelaney Posted September 13, 2012 Share Posted September 13, 2012 (edited) simplified your script...you need to define what array data point maps to the data you need, based on the communication type: 1) blindly split the data 2) depending on the type, map out the long, lat, and time 3) adds the data to an array you can then do whatever you need with that array expandcollapse popup#include <Array.au3> AutoItWinSetTitle("ArchangelProgram") AutoItSetOption("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client AutoItSetOption("MustDeclareVars", 1) Opt("TrayMenuMode", 1) HotKeySet("{ESC}", "Quit") $Debug = False Global $CommPort = "COM5", $Baudrate = 4800, $Received, $GPSHeader, $CurrentLongitude, $CurrentLatitude, $LastLongitude, $LastLatitude, $LastTime, $CurrentTime, $Longitude, $Latitude $HerbieError = True Dim $aAllReturnedData[1][3] = ["Long","Lat","Time"] While 1 ; Haven't accounted for Under/Under $bAddToArray = True If $HerbieError = True Then InitializeCommunications() EndIf $Received = _CommReceiveString(100, 5000, @CR) $aReturned = Parse ( $Received ) If IsArray ( $aReturned ) Then Switch $aReturned[1] Case "$GPGSA" ; Need to add all the mappings to standardized variables $Longitude = $aReturned[3] $Latitude = $aReturned[2] $Time = $aReturned[4] Case "$GPRMC" ; Need to add all the mappings to standardized variables $Longitude = $aReturned[3] $Latitude = $aReturned[2] $Time = $aReturned[4] Case "$GPGGA" ; Need to add all the mappings to standardized variables $Longitude = $aReturned[3] $Latitude = $aReturned[2] $Time = $aReturned[4] Case "GPGSV" ; Need to add all the mappings to standardized variables $Longitude = $aReturned[3] $Latitude = $aReturned[2] $Time = $aReturned[4] Case Else $bAddToArray = False EndSwitch Else $bAddToArray = False EndIf If $bAddToArray Then ReDim $aAllReturnedData[UBound($aAllReturnedData)+1][3] $aAllReturnedData[UBound($aAllReturnedData)-1][0] = $Longitude $aAllReturnedData[UBound($aAllReturnedData)-1][1] = $Latitude $aAllReturnedData[UBound($aAllReturnedData)-1][2] = $Time _ArrayDisplay ( $aAllReturnedData ) EndIf Sleep(500) WEnd Func Quit() If $SerialPortHandle <> -1 Then _CommClose() EndIf Exit EndFunc ;==>Quit Func Parse($Received) $aSplit = StringSplit($Received, ",") Return $aSplit EndFunc ;==>Parse Edited September 13, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 (edited) Very helpful jdelaney, but it looks like most of my script that you simplified is missing. All I see included is lat, long, time. I need all the other variables as well; sea level and all that jazz. I'm not saying do it for me; you made a great data array and once I really figure out how to do this I will be sure to convert to your simplified script and add to it. Edited September 13, 2012 by JonBMN Link to comment Share on other sites More sharing options...
jdelaney Posted September 13, 2012 Share Posted September 13, 2012 (edited) just change the 2nd dimension to include the necessary elements (Dim $aAllReturnedData[1][x] = ["Long","Lat","Time",[add your defs]])And inside the switch case, add the needed mappings.Then, on the array defining, add in those new elements....the building blocks are all there for youmodified a bit for simplicity:expandcollapse popup#include <Array.au3> AutoItWinSetTitle("ArchangelProgram") AutoItSetOption("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client AutoItSetOption("MustDeclareVars", 1) Opt("TrayMenuMode", 1) HotKeySet("{ESC}", "Quit") $Debug = False Global $CommPort = "COM5", $Baudrate = 4800, $Received, $GPSHeader, $CurrentLongitude, $CurrentLatitude, $LastLongitude, $LastLatitude, $LastTime, $CurrentTime, $Longitude, $Latitude $HerbieError = True ; ALL the data you want to store in the array...add additional data as needed, prior to the $iArray_2D_UBound Global Enum $iArray_Longitude = 0, _ $iArray_Latitude, _ $iArray_Time, _ $iArray_2D_UBound Dim $aAllReturnedData[1][$i2D_UBound] Dim $aAllReturnedData[0][$iArray_Longitude] = "Longitude" Dim $aAllReturnedData[0][$iArray_Latitude] = "Latitude" Dim $aAllReturnedData[0][$iArray_Time] = "Time" ; Etc, add as needed While 1 ; Haven't accounted for Under/Under $bAddToArray = True If $HerbieError = True Then InitializeCommunications() EndIf $Received = _CommReceiveString(100, 5000, @CR) $aReturned = Parse ( $Received ) If IsArray ( $aReturned ) Then Switch $aReturned[1] Case "$GPGSA" ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element $iLongitude = $aReturned[3] $iLatitude = $aReturned[2] $iTime = $aReturned[4] ; add additional mappings as needed Case "$GPRMC" ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element $Longitude = $aReturned[3] $Latitude = $aReturned[2] $Time = $aReturned[4] ; add additional mappings as needed Case "$GPGGA" ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element $Longitude = $aReturned[3] $Latitude = $aReturned[2] $Time = $aReturned[4] ; add additional mappings as needed Case "GPGSV" ; Need to add all the mappings to standardized variables...the 3,2,4 are bogus place holders, you need to replace with the proper array element $Longitude = $aReturned[3] $Latitude = $aReturned[2] $Time = $aReturned[4] ; add additional mappings as needed Case Else $bAddToArray = False EndSwitch Else $bAddToArray = False EndIf If $bAddToArray Then ReDim $aAllReturnedData[UBound($aAllReturnedData)+1][$iArray_2D_UBound] $aAllReturnedData[UBound($aAllReturnedData)-1][$iArray_Longitude] = $Longitude $aAllReturnedData[UBound($aAllReturnedData)-1][$iArray_Latitude] = $Latitude $aAllReturnedData[UBound($aAllReturnedData)-1][$iArray_Time] = $Time _ArrayDisplay ( $aAllReturnedData ) EndIf Sleep(500) WEnd Func Quit() If $SerialPortHandle <> -1 Then _CommClose() EndIf Exit EndFunc ;==>Quit Func Parse($Received) $aSplit = StringSplit($Received, ",") Return $aSplit EndFunc ;==>Parse Edited September 13, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 (edited) This is what worked for me Global $GetInitial = True if $GPSHeader == "$GPGGA" Then DecodeGPGGA() IF $GetInitial == True Then $IniLongitude = $Longitude $IniLatitude = $Latitude $GetInitial = False EndIf EndIf ConsoleWrite("My Initial Latitude is:" & $IniLatitude & " My Initial Longitude is:" & $IniLongitude & @CR) ConsoleWrite("My Current latitude is:" & $Latitude & " My current Longitude is:" & $Longitude & @CR) ConsoleWrite( @CR) sleep(1500) Edited September 13, 2012 by JonBMN Link to comment Share on other sites More sharing options...
BrewManNH Posted September 13, 2012 Share Posted September 13, 2012 I'm not sure what other programming languages you use, but in AutoIt the operator "==" should only be used for case sensitive string comparisons. The operator "=" is used for any other comparisons needed. Incorrect usage of that operator can cause, and has caused, script to exhibit odd behavior because of the internal manipulations that AutoIt does when it tries to compare strings to things that aren't strings. Just an FYI. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 Thank you BrewManNH I will take that into consideration. What would be your recommendation instead of using "==" for equals in autoit? You are correct I code a lot in C++ also. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 13, 2012 Share Posted September 13, 2012 "=" If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 haha DUH Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 I appreciate everyone who posted in here helping me! Link to comment Share on other sites More sharing options...
AlainB Posted September 13, 2012 Share Posted September 13, 2012 (edited) Let's say that you are going from Montreal to Vancouver. You may be interested to know how many Km (or miles) that you have already made and you may also be interested to know how many Km (or miles again) there is left to arrive to destination. The GPS is always sending the current position. This is not static as it is always changing. In order to know how far you are from Montreal you need to have stored the Montreal coordinates somewhere. This is static as it will not change. Now, all there is to do (and it is not that easy) is to calculate the distance betwen these 2 coordinates. To know the distance left to arrive to Vancouver, store the Vancouver coordinates instead of the Montreal ones. Well... I suppose that this example is a bit simplistic. I am sorry if it is too much. Edited September 13, 2012 by AlainB Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 AlainB: I just started on something like this in my code! haha Link to comment Share on other sites More sharing options...
AlainB Posted September 13, 2012 Share Posted September 13, 2012 (edited) Just out of curiosity, what is the model of your GPS module?Mine is a BlueTooth GARMIN Mobile 10:http://www.trainermed.com/docs/productos/3f70ae5ee2-1.jpg Edited September 13, 2012 by AlainB Link to comment Share on other sites More sharing options...
JonBMN Posted September 13, 2012 Author Share Posted September 13, 2012 Global SAT: BU-353 USBhttp://www.amazon.com/gp/product/images/B000PKX2KA/ref=dp_image_z_0/175-3537408-5540607?ie=UTF8&n=172526&s=gps Link to comment Share on other sites More sharing options...
JonBMN Posted September 14, 2012 Author Share Posted September 14, 2012 SEE FIRST POST; Please help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now