Jump to content
Sign in to follow this  
pille24

Write to a *.dat file

Recommended Posts

pille24

Hi,

for a project, I need to write to a dat file. I figured out, how to read from one, but hav no idea how to write to one, i also searched for it.

So, how can i write to it?

thx

Share this post


Link to post
Share on other sites
Jos

Hi,

for a project, I need to write to a dat file. I figured out, how to read from one, but hav no idea how to write to one, i also searched for it.

So, how can i write to it?

thx

FileWriteLine() ?

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
Xenobiologist

HI,

I think you can treat it like a txt file. Does that help?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
pille24

HI,

I think you can treat it like a txt file. Does that help?

So long,

Mega

U cant... thats the thing

If i open it with FileOpen($file,2) i cannot read anything:(

Share this post


Link to post
Share on other sites
Xenobiologist

U cant... thats the thing

If i open it with FileOpen($file,2) i cannot read anything:(

HI,

$file = FileOpen("test.dat", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, "Line1")
FileWrite($file, "Still Line1" & @CRLF)
FileWrite($file, "Line2")

FileClose($file)

$file = FileOpen("test.dat", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in 1 character at a time until the EOF is reached
$outPut = FileRead($file)

MsgBox(0, "Char read:", $outPut)
FileClose($file)

Open with ultraedit works fine.

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Jos

U cant... thats the thing

If i open it with FileOpen($file,2) i cannot read anything:(

What is the DAT file used for ?

Does it contain UNICODE characters ?


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
pille24

What is the DAT file used for ?

Does it contain UNICODE characters ?

well its a settings file for NBA Live 06, which id like to change...

however i can add things but not replace any...:P

U uploaded the file. Just delete the .txt

settings.dat.txt

Edited by pille24

Share this post


Link to post
Share on other sites
pille24

1. With FileReadLine

2. The Characters...not in Hex

3. Well i just want to change some values but not all of them...

thx

Share this post


Link to post
Share on other sites
Jos

1. With FileReadLine

2. The Characters...not in Hex

3. Well i just want to change some values but not all of them...

thx

Did you already check with an HEX editor if the file contain UNICODE characters ?

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
randallc

Hi,

1. How did you "read"?

With FileReadLine

probably needs a binary read of some sort to get a line properly; are there lines anyway? - probably worked coincidentally when it found a "null" perhaps?

2. what did you get back?

The Characters

Not a good answer!

3. What do you want to write?

Well i just want to change some values

Starts to sound a little edgy! ; What characters Exactly did you want to replace, with what characters Exactly, where exactly, and Why exactly?

randall

Share this post


Link to post
Share on other sites
pille24

Did you already check with an HEX editor if the file contain UNICODE characters ?

Could u explain that a bit more?

When i used FileReadLine I got back A(F etc. which is actually not, what i want...

This is a setting file which I need to change through an interface, as otherwise it would be quite annoying.

The values go from 0 to 100 an I need to change some of them. I could do it through a hex editor, but thats not what I want.

I want, for example, change the first value but keep the rest of the values, or change the 5th value, but keep the rest...

Is that a bit clearer now?

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.