Sign in to follow this  
Followers 0
blublub

Fileopen and Filewrite omg...

5 posts in this topic

#1 ·  Posted (edited)

Global $li
Global $z
Global $cc

HotKeySet("1","go")


$li=FileOpen("D:\s\c.au3",0)
$z=Number(FileReadLine($li,1))
FileClose($li)
$li=FileOpen("d:\s\c.au3",2)
Func go()
   [..]
   $z=$z+1
   FileWrite($li,$z)
Endfunc

Do
 sleep(100)
Until 0

im guessing from the help file that setting in FileOpen mode 2 = Write mode (erase previous contents) will erase my number and set the new one +1 but it doesnt its same like in mode 1 when im changing it i dont see the difference

help tell me what im doing wrong :/

edit: nvm... sry for post im stupid

its just deleting when opening not when writing constatly...

Edited by blublub

Share this post


Link to post
Share on other sites



This worked for me:

Global $sFile = "C:\Temp\Test.txt"
Global $li
Global $z
Global $cc

HotKeySet("1","go")
HotKeySet("{ESC}", "_Quit")

$li=FileOpen($sFile,0)
$z=Number(FileReadLine($li,1))
FileClose($li)

$li=FileOpen($sFile,2)
If $li = -1 Then 
    MsgBox(16, "Error", "Failed to open file: " & $sFile)
    Exit
EndIf

Do
    sleep(20)
Until 0

Func go()
   $z=$z+1
   FileWrite($li,$z)
Endfunc

Func _Quit()
    FileClose($li)
    Exit
EndFunc

:)


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

#3 ·  Posted (edited)

This worked for me:

Global $sFile = "C:\Temp\Test.txt"
Global $li
Global $z
Global $cc

HotKeySet("1","go")
HotKeySet("{ESC}", "_Quit")

$li=FileOpen($sFile,0)
$z=Number(FileReadLine($li,1))
FileClose($li)

$li=FileOpen($sFile,2)
If $li = -1 Then 
    MsgBox(16, "Error", "Failed to open file: " & $sFile)
    Exit
EndIf

Do
    sleep(20)
Until 0

Func go()
   $z=$z+1
   FileWrite($li,$z)
Endfunc

Func _Quit()
    FileClose($li)
    Exit
EndFuncoÝ÷ Ûú®¢×­+"²z-­§µçbÁ©íjÇ+m«pYky§gºfÞ­§]ûV§vÞ¯
âµè­Þ²)©ç±¦V§jبØ^­ë!¢çemê'-gºfÞ®)Ü­æ¬x½êò¶)Þ²Ír¢êìËæ¬)ÞÛ#ºËZuÛ5Û~9ë¿-¢Ø^~)^²keG­+ºÚ"µÍÛØ[ ÌÍÛBÛØ[    ÌÍÞÝÙ^]
    ][ÝÞÑLI][ÝË    ][ÝÜ]Z]   ][ÝÊB[È]Z]

BQ^][[ÂÝÙ^]
    ][ÝÌI][ÝË   ][ÝÙÛÉ][ÝÊB[ÈÛÊ
BIÌÍÛOQ[[ ][ÝÑÌLÜÚÜIÌLÛXÞZÌK]][ÝË
BIÌÍÞS[X[TXY[J   ÌÍÛKJJBQ[PÛÜÙJ    ÌÍÛJB    ÌÍÞIÌÍÞÌB    ÌÍÛOQ[[   ][ÝÑÌLÜÚÜIÌLÛXÞZÌK]][ÝËB[]J   ÌÍÛK ÌÍÞB[PÛÜÙJ    ÌÍÛJB[[ÂÂÛY
L
B[[

but thx for ur help anyway :)

Edited by blublub

Share this post


Link to post
Share on other sites

Are you saying the code you just posted does what you want or that it doesn't do what you want?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Func _go()
    Local $z = Number(StringStripWS(FileReadLine("file.txt", 1), 8))
    Local $add = $z + 1
    FileClose(FileOpen("file.txt", 2))
    FileWrite("file.txt", $add)
    Return 1
EndFunc

Edit:

Oops, forgot to erase previous content :)

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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  
Followers 0