FoxWizzy Posted September 12, 2010 Share Posted September 12, 2010 I want to have a program to encript a string and write it to a file E.x. file1 ... Then read file1 decript the code and write it to another file E.x. file2 the code works up to write the encripted string in file1 but in file2 all i get it 0 or " can you please help expandcollapse popup#include <GUIConstantsEx.au3> #include <String.au3> Opt("MustDeclareVars",1) Global $lvl, $input, $input2 start() logi() Func start() Local $msg, $button $lvl = 1 GUICreate("Test") $input = GUICtrlCreateInput("Input",0, 25) $input2 = GUICtrlCreateInput("Input2",0, 50) $button = GUICtrlCreateButton("Button",0, 75) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button Call("logi") EndSelect WEnd EndFunc Func logi() Local $read, $read2, $file, $file2, $te $read = GUICtrlRead($input) $read2 = GUICtrlRead($input2) $file = FileOpen("C:\Test.txt",2) FileWrite($file,_StringEncrypt(1,$read,$read2,$lvl)) FileClose($file) $te = FileRead($file) $file2 = FileOpen("C:\Test2.txt",2) FileWrite($file2,_StringEncrypt(0,$te,$read2,$lvl)) FileClose($file2) EndFunc Link to comment Share on other sites More sharing options...
FoxWizzy Posted September 12, 2010 Author Share Posted September 12, 2010 Any one ? Link to comment Share on other sites More sharing options...
Authenticity Posted September 12, 2010 Share Posted September 12, 2010 You've forgot to reopen the first file, in read-mode, after you closed it. Read the FileOpen function description; you don't need to close the file handle to read from it. #include <Constants.au3> $hFile = FileOpen(@ScriptDir & "\Test1.txt", 2) FileWrite($hFile, "123") FileSetPos($hFile, 0, $FILE_BEGIN) $sText = FileRead($hFile) ConsoleWrite($sText & @CRLF) FileClose($hFile) Link to comment Share on other sites More sharing options...
Tvern Posted September 12, 2010 Share Posted September 12, 2010 Authenticity is right, but It'd like to add that "logi()" on line 10 will never be called, because "start()" never returns and that line 31 should just be "logi()" instead of Call("logi"). Link to comment Share on other sites More sharing options...
FoxWizzy Posted September 13, 2010 Author Share Posted September 13, 2010 thenx Authenticity it works now 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