Sign in to follow this  
Followers 0
Gmccormack

Open File

12 posts in this topic

Hi

Sorry to ask what seems like a real dumb question but how the heck do i open a specific file

i have looked on the web and the forums and all i have seen is $file = FileOpen("test.txt", 10)

How do you nominate what drive or folder you intend to lookin

Sorry again for the dumb question, maybe i cannot see for looking

Grant

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try like this : $file = FileOpen ( "c:\foldername\test.txt", 10)

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Many thanks for the response

Im not sure what im doing wrong but but im still unable to open the file

i get no errors so i am presuming it opens ok, do i need to add something to show the file

Im completely new to all of this so please excuse my dumb questions

Thanks in advance :unsure:

Share this post


Link to post
Share on other sites

Not sure to well understand what you want to do...

Why do you want open the file ? Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

at the moment im just playing around trying to learn Autoit and this was the first step as the application i want to eventually build will need this feature

Im used to using automated software without the coding so the steps are completely different

I am trying to build a project where emails are downloaded and then parsed and the data placed into excel and control boxes in the GUI

I have done this prior with automated software very easy but you can use this software with a Gui, hence the need to do this through AutoIt

How long does it take on average to learn this ?

also can you advise of how i incorporate a GUI i have designed with Design studi with AutoIt

Thanks again

Share this post


Link to post
Share on other sites

Hi Gmccormack,

try this:

$filehandle = FileOpen("C:\Path\To\file\File.txt")

While 1
    $line = FileReadLine($filehandle)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

This was taken almost completely from the helpfile, which actually is a good place to start. :unsure:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

As say Hannes123, read the helpfile first,

there is lot of examples who can help you to create what you want ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

HI Hannes

I did look honest :unsure::>

there is that much there its a job to view it all

Ok i tried what you said and even though i get no error it still wont work

This the code with my file path

$filehandle = FileOpen("C:\Libraries\Documents\Test.txt")

While 1

$line = FileReadLine($filehandle)

If @error = -1 Then ExitLoop

MsgBox(0, "Line read:", $line)

Wend

What am i doing wrong

Share this post


Link to post
Share on other sites

Is Test.txt maybe empty?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

How long does it take on average to learn this ?

It depends. The learning curve with AutoIt is quite steep and you can achieve a lot of things very quickly. I don't think anyone can tell you how long it takes for you to learn it - unless he has worked with you for a while. My trainees usually take 3-4 weeks until they can code some simple applications. Some are faster some "not that fast" and some will never learn. :>

also can you advise of how i incorporate a GUI i have designed with Design studi with AutoIt

You can use KodaForm editor (that comes along with Scite4AutoIT) to build GUIs, but from my point of view this belongs to the more complex things to do with AutoIT. Take your time and start slow. Read the manual. Search the forum. :unsure:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Put the following lines after the FileOpen to check if file opened for reading is OK:

If $filehandle = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

And consider what UEZ said. :unsure:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

No the text file isnt empty.

I shall trwal through the help files and try and learn some basics b4 i bore you guys silly with dumb questions

I have to add that the support and help from you guys is awesome

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