GreatWest Posted February 8, 2007 Posted February 8, 2007 I have a routine that collects information from a hand held scanner. This is a simple GUICreate with a CreateInput box. The scanner is a keyboard wedge type so once an item has been scanned the alpha numerics show up in the input box just as if they were typed on a keyboard. I then use a simple While/Wend to check to see if the Submit button has been pressed. Next the data is placed into the SQL database with a Func/EndFunc routine. Then the script exits. No issues, the data is scanned, variables set, and data goes into my SQL table without issue. I figured I would just use a simple Do/Until to loop the routine but it doesn't work. I can't even run the script once I put the Do/Until in. So the present script goes something like this - Create/Open GUI.Scan the bar code into the input box.Press the Submit button (using a While/Wend)Put the variable information into SQL with a Func/EndFuncExit the scriptIf I put the Do up near the start of the script with the Until at the bottom. I get the following error -S:\AIS.au3(145,2) : ERROR: missing Until <expr>. Func ^S:\AIS.au3(15,1) : REF: missing Until <expr>.Do^S:\AIS.au3(153,1) : ERROR: syntax errorUntil^S:\AIS.au3 - 2 error(s), 0 warning(s)Now if I leave the Do/Until there and just comment out the SQL function the script runs fine, repeats itself until I kill the script. $DSN = "Provider=SQLOLEDB;SERVER=XXXXXXX;DATABASE=XXXXXX;UID=XXXXXX;PWD=XXXXXX" ExecuteQuery($DSN, $SQLQuery) Func ExecuteQuery ($DSN,$SQLQuery) $adoSQL = $SQLQuery $adoCon = ObjCreate("ADODB.Connection") $adoCon.Open ($DSN) $adoCon.Execute($adoSQL) $adoCon.Close EndFuncSo pretty much if I take the entire function statement above out of the script the script runs just fine and loops just fine. If I put the function back in, I get the error about the Do/Until loop. GW
PaulIA Posted February 8, 2007 Posted February 8, 2007 It would be better if you would post the entire script for us to look at. You've got a syntax error in your code and we'd only be guessing where it is without looking at the code. Auto3Lib: A library of over 1200 functions for AutoIt
GreatWest Posted February 8, 2007 Author Posted February 8, 2007 It would be better if you would post the entire script for us to look at. You've got a syntax error in your code and we'd only be guessing where it is without looking at the code.I doubt it's a syntax error because I'm just adding a Do/Until but here's the code anyway with some parts blocked out for security reasons of course. I know it looks like crap so no need to tell me that - it works for the most part and right now I don't have to much time for cleanup. I just don't know why I can't loop a function.; ----------------------------------------------------------------------------------; AMS Check In;; Script Function: This script allows IT Techs to check in computers using either; a keyboard wedge scanner or manually by typing in the computers service tag.; -----------------------------------------------------------------------------------#Include <process.au3>#Include <Date.au3>#include<GUIConstants.au3>GUICreate("Check In", 320,260)GUISetFont(12,600,1,"Arial")GUICtrlCreateLabel("Quick Computer Check-In",55,10)GUICtrlCreateLabel("Asset Status ",100,50)GUISetState(@SW_SHOW) ; first number is horizontal, second number is verticalGUISetFont(12,100,1,"Arial")$AssetTag = GUICtrlCreateCombo("",80,80,170)GUICtrlSetData(-1,"Ready to Deploy|Down|Idle","Ready to Deploy")$AST = GUICtrlRead($AssetTag)$AssetStatus = $ASTGUISetFont(12,600,1,"Arial")GUICtrlCreateLabel("Scan Service Tag ",90,130); first number is horizontal, second number is verticalGUISetFont(12,100,1,"Arial")$SERVTAG = GUICtrlCreateInput("",80,160,170)Send("{TAB}{TAB}")$AssetCurrency = ""$AssetID = ""$Category = "Hardware"$Manufacturer = ""$Item = ""$HowUsed = ""$Region = "Americas - U.S.A. - Texas"$Site = "Dallas"$AssetLoc = "Building 2"$TITagNum = ""$EndUserEmpID = "Inventory"$ReportingMgrAID = ""$SystemID = "CN0XInventory"$MaintVenName = ""$ReceivedDate = ""$InstallDate = ""$DisposalDate = ""$OwnerCostCenter = ""$PRNumber = ""$PONumber = ""$OwnershipType = "Expense"$SupportGroup = "IT"$LoanerReturnDate = ""$UserDefined1 = ""$UserDefined2 = ""$DATERUN = @MON & "/" & @MDAY & "/" & @YEAR$UserDefined3 = $DATERUN$btn = GUICtrlCreateButton ("Submit", 135, 210, 60, 20)GUISetState () $msg = 0While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn exitloop EndSelectWend$ST = GUICtrlRead($SERVTAG)$SerialNumber = $ST$TITagNum = "ES" & $SerialNumber$SQLQuery = "INSERT INTO Table (" _ & "AssetCurrency," _ & "AssetID," _ & "AssetStatus," _ & "Category," _ & "Manufacturer," _ & "Item," _ & "HowUsed," _ & "Region," _ & "Site," _ & "AssetLoc," _ & "TITagNum," _ & "EndUserEmpID," _ & "ReportingMgr_ID," _ & "SerialNumber," _ & "SystemID," _ & "MaintVenName," _ & "ReceivedDate," _ & "InstallDate," _ & "DisposalDate," _ & "OwnerCostCenter," _ & "PRNumber," _ & "PONumber," _ & "OwnershipType," _ & "SupportGroup," _ & "LoanerReturnDate," _ & "UserDefined1," _ & "UserDefined2," _ & "UserDefined3" _ & ") VALUES (" _ & "'" & $AssetCurrency & "'" & "," _ & "'" & $AssetID & "'" & "," _ & "'" & $AssetStatus & "'" & "," _ & "'" & $Category & "'" & "," _ & "'" & $Manufacturer & "'" & "," _ & "'" & $Item & "'" & "," _ & "'" & $HowUsed & "'" & "," _ & "'" & $Region & "'" & "," _ & "'" & $Site & "'" & "," _ & "'" & $AssetLoc & "'" & "," _ & "'" & $TITagNum & "'" & "," _ & "'" & $EndUserEmpID & "'" & "," _ & "'" & $ReportingMgr_ID & "'" & "," _ & "'" & $SerialNumber & "'" & "," _ & "'" & $SystemID & "'" & "," _ & "'" & $MaintVenName & "'" & "," _ & "'" & $ReceivedDate & "'" & "," _ & "'" & $InstallDate & "'" & "," _ & "'" & $DisposalDate & "'" & "," _ & "'" & $OwnerCostCenter & "'" & "," _ & "'" & $PRNumber & "'" & "," _ & "'" & $PONumber & "'" & "," _ & "'" & $OwnershipType & "'" & "," _ & "'" & $SupportGroup & "'" & "," _ & "'" & $LoanerReturnDate & "'" & "," _ & "'" & $UserDefined1 & "'" & "," _ & "'" & $UserDefined2 & "'" & "," _ & "'" & $UserDefined3 & "'" _ & ")" $DSN = "Provider=SQLOLEDB;SERVER=********;DATABASE=*****;UID=*****;PWD=******" ExecuteQuery($DSN, $SQLQuery) Func ExecuteQuery ($DSN,$SQLQuery) $adoSQL = $SQLQuery $adoCon = ObjCreate("ADODB.Connection") $adoCon.Open ($DSN) $adoCon.Execute($adoSQL) $adoCon.Close EndFuncI just need it to loop back to the top and start over again after putting the data into the SQL database. Thanks for any suggestions.GW
PaulIA Posted February 8, 2007 Posted February 8, 2007 Wish I could help you out, but your code doesn't compile. Basically, you need to take all of the straight line code and put it into functions. Then, when your button is pressed, just call the functions from the message loop. Auto3Lib: A library of over 1200 functions for AutoIt
GEOSoft Posted February 8, 2007 Posted February 8, 2007 (edited) Like Paul said, better to post the whole script. This smacks of a missing EndIf, Wend, EndSelect & etc. In other words, a syntax error. Edited February 8, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
GreatWest Posted February 8, 2007 Author Posted February 8, 2007 Wish I could help you out, but your code doesn't compile. Basically, you need to take all of the straight line code and put it into functions. Then, when your button is pressed, just call the functions from the message loop.It compiles just fine using BetaCompile in SciTE and runs. As mentioned before I know the code is not clean but it does compile and run. GW
GreatWest Posted February 8, 2007 Author Posted February 8, 2007 Like Paul said, better to post the whole script. This smacks of a missing EndIf, Wend, EndSelect & etc. In other words, a syntax error.Already done before you got around to posting your response, and you mention that there are misisng EndIf's - there are no IF statements so why would I need an EndIf, same with Wend. I have one While and it does have the closing Wend statement, and EndSelect I have it. GW
GreatWest Posted February 8, 2007 Author Posted February 8, 2007 Wish I could help you out, but your code doesn't compile. Basically, you need to take all of the straight line code and put it into functions. Then, when your button is pressed, just call the functions from the message loop.I'm not sure I understand what your saying here. Here's what I need - a gui that opens and places the cursor in the input box so all that has to be done is for the trigger on the scanner to be pressed. Once the text read from the scanner appears in the input box then I need a button pressed to submit the informaiton into the SQL database. Then the text in the input box should be cleared and I get to to do the entire processes again.I'm not sure how to put all the straight line code into fucntions. I'll have to look at the help file to see how to do that. Thanks for the suggestion.GW
/dev/null Posted February 8, 2007 Posted February 8, 2007 I doubt it's a syntax error because I'm just adding a Do/Until but here's the code anyway with some parts blocked out for security reasons of course. I know it looks like crap so no need to tell me that - it works for the most part and right now I don't have to much time for cleanup. I just don't know why I can't loop a function.well there is at least one error, which prevents me from running it withing Scite.$ReportingMgrAID should be $ReportingMgr_ID __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
GreatWest Posted February 8, 2007 Author Posted February 8, 2007 well there is at least one error, which prevents me from running it withing Scite.$ReportingMgrAID should be $ReportingMgr_IDFrom my post with the code - "here's the code anyway with some parts blocked out for security reasons of course"I just missed the AID portion.GW
/dev/null Posted February 8, 2007 Posted February 8, 2007 From my post with the code - "here's the code anyway with some parts blocked out for security reasons of course" I just missed the AID portion. GW Try this: expandcollapse popup; ---------------------------------------------------------------------------------- ; AMS Check In ; ; Script Function: This script allows IT Techs to check in computers using either ; a keyboard wedge scanner or manually by typing in the computers service tag. ; ----------------------------------------------------------------------------------- #Include <process.au3> #Include <Date.au3> #include<GUIConstants.au3> ;-------------------------------------------------------------- ;-- Global variables ;-------------------------------------------------------------- $AssetCurrency = "" $AssetID = "" $Category = "Hardware" $Manufacturer = "" $Item = "" $HowUsed = "" $Region = "Americas - U.S.A. - Texas" $Site = "Dallas" $AssetLoc = "Building 2" $TITagNum = "" $EndUserEmpID = "Inventory" $ReportingMgr_ID = "" $SystemID = "CN0XInventory" $MaintVenName = "" $ReceivedDate = "" $InstallDate = "" $DisposalDate = "" $OwnerCostCenter = "" $PRNumber = "" $PONumber = "" $OwnershipType = "Expense" $SupportGroup = "IT" $LoanerReturnDate = "" $UserDefined1 = "" $UserDefined2 = "" $DATERUN = @MON & "/" & @MDAY & "/" & @YEAR $UserDefined3 = $DATERUN GUICreate("Check In", 320, 260) GUISetFont(12, 600, 1, "Arial") GUICtrlCreateLabel("Quick Computer Check-In", 55, 10) GUICtrlCreateLabel("Asset Status ", 100, 50) GUISetState(@SW_SHOW) ; first number is horizontal, second number is vertical GUISetFont(12, 100, 1, "Arial") $AssetTag = GUICtrlCreateCombo("", 80, 80, 170) GUICtrlSetData(-1, "Ready to Deploy|Down|Idle", "Ready to Deploy") $AST = GUICtrlRead($AssetTag) $AssetStatus = $AST GUISetFont(12, 600, 1, "Arial") GUICtrlCreateLabel("Scan Service Tag ", 90, 130) ; first number is horizontal, second number is vertical GUISetFont(12, 100, 1, "Arial") $SERVTAG = GUICtrlCreateInput("", 80, 160, 170) GUICtrlSetState($SERVTAG,$GUI_FOCUS) ;Send("{TAB}{TAB}") $btn = GUICtrlCreateButton("Submit", 135, 210, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $ST = GUICtrlRead($SERVTAG) InsertIntoDB($ST) GUICtrlSetData($SERVTAG,"") GUICtrlSetState($SERVTAG,$GUI_FOCUS) EndSelect WEnd $ST = GUICtrlRead($SERVTAG) Func InsertIntoDB($SerialNumber) $TITagNum = "ES" & $SerialNumber $SQLQuery = "INSERT INTO Table (" _ & "AssetCurrency," _ & "AssetID," _ & "AssetStatus," _ & "Category," _ & "Manufacturer," _ & "Item," _ & "HowUsed," _ & "Region," _ & "Site," _ & "AssetLoc," _ & "TITagNum," _ & "EndUserEmpID," _ & "ReportingMgr_ID," _ & "SerialNumber," _ & "SystemID," _ & "MaintVenName," _ & "ReceivedDate," _ & "InstallDate," _ & "DisposalDate," _ & "OwnerCostCenter," _ & "PRNumber," _ & "PONumber," _ & "OwnershipType," _ & "SupportGroup," _ & "LoanerReturnDate," _ & "UserDefined1," _ & "UserDefined2," _ & "UserDefined3" _ & ") VALUES (" _ & "'" & $AssetCurrency & "'" & "," _ & "'" & $AssetID & "'" & "," _ & "'" & $AssetStatus & "'" & "," _ & "'" & $Category & "'" & "," _ & "'" & $Manufacturer & "'" & "," _ & "'" & $Item & "'" & "," _ & "'" & $HowUsed & "'" & "," _ & "'" & $Region & "'" & "," _ & "'" & $Site & "'" & "," _ & "'" & $AssetLoc & "'" & "," _ & "'" & $TITagNum & "'" & "," _ & "'" & $EndUserEmpID & "'" & "," _ & "'" & $ReportingMgr_ID & "'" & "," _ & "'" & $SerialNumber & "'" & "," _ & "'" & $SystemID & "'" & "," _ & "'" & $MaintVenName & "'" & "," _ & "'" & $ReceivedDate & "'" & "," _ & "'" & $InstallDate & "'" & "," _ & "'" & $DisposalDate & "'" & "," _ & "'" & $OwnerCostCenter & "'" & "," _ & "'" & $PRNumber & "'" & "," _ & "'" & $PONumber & "'" & "," _ & "'" & $OwnershipType & "'" & "," _ & "'" & $SupportGroup & "'" & "," _ & "'" & $LoanerReturnDate & "'" & "," _ & "'" & $UserDefined1 & "'" & "," _ & "'" & $UserDefined2 & "'" & "," _ & "'" & $UserDefined3 & "'" _ & ")" $DSN = "Provider=SQLOLEDB;SERVER=********;DATABASE=*****;UID=*****;PWD=******" MsgBox(0, "", $SQLQuery); <<== REPLACE THIS with ExecuteQuery() ;ExecuteQuery($DSN, $SQLQuery) EndFunc ;==>InsertIntoDB Func ExecuteQuery($DSN, $SQLQuery) $adoSQL = $SQLQuery $adoCon = ObjCreate("ADODB.Connection") $adoCon.Open ($DSN) $adoCon.Execute ($adoSQL) $adoCon.Close EndFunc ;==>ExecuteQuery __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
GreatWest Posted February 8, 2007 Author Posted February 8, 2007 (edited) Try this:The database isn't wanting to accept the data "test.au3 (159) : ==> The requested action with this object has failed:"I've run into this before when trying to work with our database. You've given me a couple of ideas and new things to try - greatly appreceated. I'll keep trying and see if I can figure out what I'm doing wrong with the database.GWPS> Also greatly appreceate you leaving the old crap code in there just commenting it out and putting in how it should be done such as the $GUI_FOCUS instead of my silly tabs! keep doing that when you help others - it's great! Edited February 8, 2007 by GreatWest
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