FoxWizzy 0 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 Share this post Link to post Share on other sites
Authenticity 13 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) Share this post Link to post Share on other sites
Tvern 11 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"). Share this post Link to post Share on other sites
FoxWizzy 0 Posted September 13, 2010 thenx Authenticity it works now Share this post Link to post Share on other sites