I trying to do fast FileReverse script
Now I Have Some question
Q1: first Loop how I see works well but Why second do only 2 steps and scripts crash
Q2: why first Loop crash when I remove "Local $start_time = TimerInit()"
Q3: why first Loop crash when I remove "#include <WinAPI.au3>"
Please help
source script - example
Now I Have Some question
Q1: first Loop how I see works well but Why second do only 2 steps and scripts crash
Q2: why first Loop crash when I remove "Local $start_time = TimerInit()"
Q3: why first Loop crash when I remove "#include <WinAPI.au3>"
Please help
source script - example
[ autoit ]
#include <WinAPI.au3> #include <String.au3> Global $v_test = '' Local $start_time = TimerInit() ;~ $f_plik = @ScriptDir & '\TEST.pdf' ; Size = 4,00 KB (Bytes: 4 096) $f_plik = @ScriptDir & '\TEST2.pdf' ; Size = 142 KB (Bytes: 146 396) For $i = 1 To 1000 _ConsoleOut('--> --> test : ' & $i) _FileReverse($f_plik) Next For $i = 1 To 1000 _ConsoleOut('--> --> test : ' & $i) _FileReverse_2($f_plik) Next ;###################################################################################################################################### Func _FileReverse($f_file_to_reverse) _ConsoleOut('--> STEP 1: _FileReverse($f_file_to_reverse)') If $v_test = '' Then Local $f_handle = FileOpen($f_file_to_reverse, 16 + 32) $v_test = FileRead($f_handle) FileClose($f_handle) EndIf ;~ _WaitFileIsNoUsed($f_file_to_reverse) ;~ Local $v_test__1_len = StringLen($v_test) Local $s_REVERSE2 = _StringReverse2($v_test) Local $v_test__5_LE2 = BinaryToString($s_REVERSE2) $s_REVERSE2 = '' Return $v_test__5_LE2 EndFunc ;==>_FileReverse ;###################################################################################################################################### Func _FileReverse_2($f_file_to_reverse) _ConsoleOut('--> STEP 1: _FileReverse($f_file_to_reverse)') Local $f_handle = FileOpen($f_file_to_reverse, 16 + 32) Local $v_test_Local = FileRead($f_handle) FileClose($f_handle) ;~ _WaitFileIsNoUsed($f_file_to_reverse) ;~ Local $v_test__1_len = StringLen($v_test) Local $s_REVERSE2 = _StringReverse2($v_test_Local) Local $v_test__5_LE2 = BinaryToString($s_REVERSE2) $s_REVERSE2 = '' Return $v_test__5_LE2 EndFunc ;==>_FileReverse_2 ;###################################################################################################################################### Func _StringReverse2($s_String) _ConsoleOut('--> STEP 2: _StringReverse2($s_String)') Local $i_len = StringLen($s_String) If $i_len < 1 Then Return SetError(1, 0, "") Local $str = "char[" & $i_len + 1 & "]" Local $t_chars = DllStructCreate($str) DllStructSetData($t_chars, 1, $s_String) Local $a_rev = DllCall("msvcrt.dll", "ptr:cdecl", "_wcsrev", "struct*", $t_chars) Local $v_error = @error If $v_error Or $a_rev[0] = 0 Then Return SetError(2, 0, "") $v_var_to_return = $a_rev[0] ;~ Local $v_var_to_return = DllStructGetData($t_chars, 1) ;~ DllStructSetData($t_chars, 1, '') $str = 0 $t_chars = '' Return $v_var_to_return EndFunc ;==>_StringReverse2 ;###################################################################################################################################### Func _ConsoleOut($string = '') ConsoleWrite($string & @CRLF) EndFunc ;==>_ConsoleOut ;######################################################################################################################################