Jump to content
Sign in to follow this  
Trejuzz

Reading/writing from/to file

Recommended Posts

Trejuzz

Hello, again I felt into trouble... :sweating:

I would like to ask, how can you read from .txt file or write to it in autoit? (something similar to fstream functions in c++). I tried to write somewhat of a code, but it isn't working, maybe I'm on the wrong path, I need some guidance ^.^

To save time, I would like to ask, if there is function that includes email options, for example send to email, in autoit?

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>


Local Const $sFilePath = "C:\Users\Adolfas\Desktop\Prog\Autoit\result.txt"
Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
FileWrite ($hFileOpen,"Hello")

Share this post


Link to post
Share on other sites
Jos

So you think that when you open a file for read you can write to it?

Maybe opening it for Write or Append works better. :)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     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
water

Check example 2 of FileOpen in the help file. It explains how to read and write from a file at the same time.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

 

To save time, I would like to ask, if there is function that includes email options, for example send to email, in autoit?

Depends on the mail client you want to use (Outlook, SMTP ...)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
computergroove

Stripped down:

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>


Example()


Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = "c:\LiqList.txt"


    ; Open the file for read/write access.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_OVERWRITE)


    ; Write some data.
    FileWrite($hFileOpen, "Hello" & @CRLF)


    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)


EndFunc

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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  

×