Jump to content
Sign in to follow this  
erezlevi

fileopen unicode encoding doesn't work

Recommended Posts

erezlevi

hi,

when using the following code I am having problems saving the file as unicode. the : $file=fileopen ("c:\2905_96xxdata.txt",128)

does not work for me. can someone help please???

#AutoIt3Wrapper_outfile=GUI.exe
#AutoIt3Wrapper_run_debug_mode=Y
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <File.au3>
GUICreate("My GUI") ; will create a dialog box that when displayed is centered

; Run the GUI until the dialog is closed
Opt("GUICoordMode",2)

$widthCell=70
GUICtrlCreateLabel ("IPphonevalues-change",20,20)
$change=GUICtrlCreateLabel ("first contact labe to change",  -50, 50,150)
$change3=GUICtrlCreateInput ("please insert new label",-10,-20)
$changeicon=GUICtrlCreateButton ("change",-150,30)
GUISetState ()
$msg = 0

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg=$changeicon
            $e=GUICtrlRead($change3)
            $file=fileopen ("c:\2905_96xxdata.txt",128)
            $filechange=_FileWriteToLine ("c:\2905_96xxdata.txt",1,"ABKNAME001="&$e,1)
            FileClose ($file)
            MsgBox (0,"done!","")
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    fileopen ("c:\2905_96xxdata.txt",128)
    
Wend

Share this post


Link to post
Share on other sites
Jos

hi,

when using the following code I am having problems saving the file as unicode. the : $file=fileopen ("c:\2905_96xxdata.txt",128)

does not work for me. can someone help please???

#AutoIt3Wrapper_outfile=GUI.exe
#AutoIt3Wrapper_run_debug_mode=Y
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <File.au3>
GUICreate("My GUI"); will create a dialog box that when displayed is centered

; Run the GUI until the dialog is closed
Opt("GUICoordMode",2)

$widthCell=70
GUICtrlCreateLabel ("IPphonevalues-change",20,20)
$change=GUICtrlCreateLabel ("first contact labe to change",  -50, 50,150)
$change3=GUICtrlCreateInput ("please insert new label",-10,-20)
$changeicon=GUICtrlCreateButton ("change",-150,30)
GUISetState ()
$msg = 0

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg=$changeicon
            $e=GUICtrlRead($change3)
            $file=fileopen ("c:\2905_96xxdata.txt",128)
            $filechange=_FileWriteToLine ("c:\2905_96xxdata.txt",1,"ABKNAME001="&$e,1)
            FileClose ($file)
            MsgBox (0,"done!","")
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    fileopen ("c:\2905_96xxdata.txt",128)
    
Wend
The _FileWriteToLine() UDF doesn;t use your FileOpen() handle and methode but opens the file itself.

You will have to copy the Udf into your own script and change it to what you want.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
erezlevi

The _FileWriteToLine() UDF doesn;t use your FileOpen() handle and methode but opens the file itself.

You will have to copy the Udf into your own script and change it to what you want.

Jos

hi I tried this also, and it does not work for some reason:

#include <File.au3>
$file=_FileCreate ("c:\erez1234.txt")
$file1=FileOpen ("c:\erez1234.txt",32)
_FileWriteToLine ($file1,1,"ereztest",1)
FileClose ($file1)

Share this post


Link to post
Share on other sites
Jos

hi I tried this also, and it does not work for some reason:

#include <File.au3>
$file=_FileCreate ("c:\erez1234.txt")
$file1=FileOpen ("c:\erez1234.txt",32)
_FileWriteToLine ($file1,1,"ereztest",1)
FileClose ($file1)
I know and as stated: The UDF does not use a filehandle thus it will never work using the current version of _FileWriteToLine().

You will have to created you own function to be able to write to the first record....


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
erezlevi

I know and as stated: The UDF does not use a filehandle thus it will never work using the current version of _FileWriteToLine().

You will have to created you own function to be able to write to the first record....

can someone help with an example of what can be done? where to look at in order to start?

Share this post


Link to post
Share on other sites
PsaltyDS

hi I tried this also, and it does not work for some reason:

#include <File.au3>
$file=_FileCreate ("c:\erez1234.txt")
$file1=FileOpen ("c:\erez1234.txt",32)
_FileWriteToLine ($file1,1,"ereztest",1)
FileClose ($file1)
Fix your modes. FileOpen() with just 32 means 0 + 32, which is read mode. You want 1 + 32 = 33 for append, or 2 + 32 = 34 for overwrite.

Next, as Jos said (TWICE!) you can't presently use a file handle for the _FileWriteToLine() function. You would have to open the File.au3 UDF, and dig into that function for changes to make it do what you want.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
erezlevi

Fix your modes. FileOpen() with just 32 means 0 + 32, which is read mode. You want 1 + 32 = 33 for append, or 2 + 32 = 34 for overwrite.

Next, as Jos said (TWICE!) you can't presently use a file handle for the _FileWriteToLine() function. You would have to open the File.au3 UDF, and dig into that function for changes to make it do what you want.

:)

first thanks for your answers:

I'v decided to choose an external ANSI2INI converter using controlsend funtions to transform the file to UNICODE.

Share this post


Link to post
Share on other sites
PsaltyDS

first thanks for your answers:

I'v decided to choose an external ANSI2INI converter using controlsend funtions to transform the file to UNICODE.

So... you found this too hard?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.