Jump to content

Recommended Posts

Posted

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

  • Developers
Posted

  pille24 said:

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() ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

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

Posted

  th.meger said:

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:(

Posted (edited)

  pille24 said:

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

  • Developers
Posted

  pille24 said:

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 ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

  JdeB said:

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
  • Developers
Posted

  pille24 said:

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 ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Hi,

  Quote

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?

  Quote

2. what did you get back?

The Characters

Not a good answer!

  Quote

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

Posted

  JdeB said:

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?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...