gilloub Posted August 29, 2007 Share Posted August 29, 2007 (edited) Hi, I'm discovering this interesting tool and maybe i missed something about how use function, i'm looking for your light to help me solving a problem. I have to make a script wich convert text and save it in file and then i take some function and when i launch these function it show me an error. if someone has any idea expandcollapse popup#NoTrayIcon $ok=0 If($CmdLine[1]="save") Then $a=FileOpen ($CmdLine[2],2) $ok=FileWrite($a,ClipGet()) FileClose($a) EndIf If($CmdLine[1]="saveUnicode2Utf8") Then $a=FileOpen ($CmdLine[2],2) $string = Unicode2Utf8(ClipGet()) $ok=FileWrite($a,$string) FileClose($a) EndIf If($CmdLine[1]="saveUtf82Unicode") Then $a=FileOpen ($CmdLine[2],2) $string = ClipGet() saveUtf82Unicode($string) $ok=FileWrite($a,$string) FileClose($a) EndIf If($CmdLine[1]="saveAsc2Unicode") Then $a=FileOpen ($CmdLine[2],2) $string = ClipGet() saveAsc2Unicode($string) $ok=FileWrite($a,$string) FileClose($a) EndIf If($CmdLine[1]="saveUnicode2Asc") Then $a=FileOpen ($CmdLine[2],2) $string = ClipGet() saveUnicode2Asc($string) $ok=FileWrite($a,$string) FileClose($a) EndIf If($CmdLine[1]="append") Then $a=FileOpen ($CmdLine[2],1) $ok=FileWrite($a,ClipGet()) FileClose($a) EndIf ConsoleWrite ($ok) exit Func Utf82Unicode($Utf8String) Local $BufferSize = StringLen($Utf8String) * 2 Local $Buffer = DllStructCreate("byte[" & $BufferSize & "]") Local $Return = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _ "int", 65001, _ "int", 0, _ "str", $Utf8String, _ "int", StringLen($Utf8String), _ "ptr", DllStructGetPtr($Buffer), _ "int", $BufferSize) Local $UnicodeString = StringLeft(DllStructGetData($Buffer, 1), $Return[0] * 2) $Buffer = 0 Return $UnicodeString EndFunc Func Asc2Unicode($AscString) Local $BufferSize = StringLen($AscString) * 2 Local $Buffer = DllStructCreate("byte[" & $BufferSize & "]") Local $Return = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _ "int", 0, _ "int", 0, _ "str", $AscString, _ "int", StringLen($AscString), _ "ptr", DllStructGetPtr($Buffer), _ "int", $BufferSize) Local $UnicodeString = StringLeft(DllStructGetData($Buffer, 1), $Return[0] * 2) $Buffer = 0 Return $UnicodeString EndFunc Func Unicode2Asc($UniString) If Not IsBinaryString($UniString) Then SetError(1) Return $UniString EndIf Local $BufferLen = StringLen($UniString) Local $Input = DllStructCreate("byte[" & $BufferLen & "]") Local $Output = DllStructCreate("char[" & $BufferLen & "]") DllStructSetData($Input, 1, $UniString) Local $Return = DllCall("kernel32.dll", "int", "WideCharToMultiByte", _ "int", 0, _ "int", 0, _ "ptr", DllStructGetPtr($Input), _ "int", $BufferLen / 2, _ "ptr", DllStructGetPtr($Output), _ "int", $BufferLen, _ "int", 0, _ "int", 0) Local $AscString = DllStructGetData($Output, 1) $Output = 0 $Input = 0 Return $AscString EndFunc Func Unicode2Utf8($UniString) If Not IsBinaryString($UniString) Then SetError(1) Return $UniString EndIf Local $UniStringLen = StringLen($UniString) Local $BufferLen = $UniStringLen * 2 Local $Input = DllStructCreate("byte[" & $BufferLen & "]") Local $Output = DllStructCreate("char[" & $BufferLen & "]") DllStructSetData($Input, 1, $UniString) Local $Return = DllCall("kernel32.dll", "int", "WideCharToMultiByte", _ "int", 65001, _ "int", 0, _ "ptr", DllStructGetPtr($Input), _ "int", $UniStringLen / 2, _ "ptr", DllStructGetPtr($Output), _ "int", $BufferLen, _ "int", 0, _ "int", 0) Local $Utf8String = DllStructGetData($Output, 1) $Output = 0 $Input = 0 Return $Utf8String EndFunc thanks Edited August 29, 2007 by gilloub Link to comment Share on other sites More sharing options...
thor42 Posted August 29, 2007 Share Posted August 29, 2007 Which Error was shown? Depending on the version used maybe "IsBinaryString was renamed to IsBinary"? Link to comment Share on other sites More sharing options...
gilloub Posted August 29, 2007 Author Share Posted August 29, 2007 I use AutoIt 3 Link to comment Share on other sites More sharing options...
thor42 Posted August 29, 2007 Share Posted August 29, 2007 I use AutoIt 3I assumed you are using AutoIT3. The question was, which version of AutoIT3 you are using.Try to rename isBinaryString into isBinary inside the script, because according to the changelog the function has been renamed. It depends on the Version of autoit you are using. Could you write the error message in detail? Link to comment Share on other sites More sharing options...
herewasplato Posted August 29, 2007 Share Posted August 29, 2007 I use AutoIt 3Welcome to the forum. Perhaps version info like v3.2.4.9 or v3.2.7.0 (beta). This info can be found on the intro page of the help file or run this:MsgBox(0, "AutoIt Version", @AutoItVersion) -MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] 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