computergroove Posted May 29, 2008 Share Posted May 29, 2008 When I run this script I can open barcode.ini and see the contents and it comes out right. However when I try to call barcodes.ini later in the script I keep getting the "The code you entered "&$user_input&" was not found in the database" error meaning that the barcode.ini file that is being created before the switch function. I flagged the section giving me the error. What am I doing wrong here? expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=Barcode.exe #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <string.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") $Form1 = GUICreate("Scan Barcode", 150, 22, 1, 1); creats a GUI window (Width, Height, Left, Top,) $edit_field = GUICtrlCreateInput("", 0, 0, 148, 21); ( "text", left, top , width , height) GUISetState() ; temp.txt is a file that has the encrypted file string stored in it ; barcode.ini is a file that is used as a temp file for storing the data If FileExists("barcode.ini") Then;deletes the temp file barcode.ini in case of a computer crash FileDelete("barcode.ini") EndIf Local $file FileOpen("temp.txt", 0); calls the file temp.txt for reading later ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Cant find barcode.ini.") Exit EndIf $file = FileRead("temp.txt"); reads temp.txt and assigns the data to $file $Decrypted_Data = _StringEncrypt (0 , $file, "1234"); decrypts the string "$file" - Tested FileWrite("barcode.ini", $Decrypted_Data); writes the data to barcode.ini While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE FileDelete("Barcode.ini") Exit Case $edit_field $user_input = GUICtrlRead($edit_field); sets $user_input to whatever was typed in the edit box If IniRead("barcode.ini", "AviCodes", $user_input, "no entry") = "no entry" Then ; #################### here's where the error message is coming from ########################## MsgBox(16, "Code not found", "The code you entered "&$user_input&" was not found in the database",3) : ############################################################################# WinActivate("Scan Barcode") GUICtrlSetData($edit_field, "");erases not successful input Else $video_file = (@ScriptDir & "\" & IniRead("barcode.ini", "AviCodes", $user_input, "no entry")) Run (@ProgramFilesDir & "\K-Lite Codec Pack\Media Player Classic\mplayerc.exe " & Chr(34) & $video_file & Chr(34) & " -close") Sleep (5000) WinActivate("Scan Barcode") GUICtrlSetData($edit_field, "");erases not successful input EndIf EndSwitch WEnd ;EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
enaiman Posted May 29, 2008 Share Posted May 29, 2008 You can't do this directly : FileWrite("barcode.ini", $Decrypted_Data); writes the data to barcode.ini without opening the file first in write mode. Replace it with: $barcode_ini = FileOpen("barcode.ini", 2) ;opens the file in write mode (it will create the file if it doesn't exist) FileWrite($barcode_ini, $Decrypted_Data); writes the data to barcode.ini FileClose($barcode_ini) ;closes the file SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
computergroove Posted May 29, 2008 Author Share Posted May 29, 2008 I tried this but I am getting the same error. $file = FileRead("temp.txt"); reads temp.txt and assigns the data to $file FileOpen("barcode.ini", 2);opens the file in write mode (it will create the file if it doesn't exist) $Decrypted_Data = _StringEncrypt (0 , $file, "1234"); decrypts the string "$file" - Tested FileWrite("barcode.ini", $Decrypted_Data); writes the data to barcode.ini FileClose("barcode.ini");closes the file I also tried it without the FileClose("barcode.ini") section with the same results. If someone needs to try this in their machine then I have attached the file temp.txt here -> temp.txt Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
enaiman Posted May 29, 2008 Share Posted May 29, 2008 (edited) Your barcode.ini files looks like: [AviCodes] 12345;avi1.avi while it should look like [AviCodes] 12345=avi1.avi "=" instead of ";" I guess you haven't properly built your ini file or you have encrypted the wrong one - have a look at my previous posts and notice how the ini file structure is. Because ";" replacing the "=" you get errors ... Edited May 29, 2008 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
computergroove Posted May 29, 2008 Author Share Posted May 29, 2008 Oops. Your right. Thanks Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html 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