Sign in to follow this  
Followers 0
Immensee

Loading a File via a .txt file

6 posts in this topic

Hello, i'm new in here, could someone help me?

I'm a guru with PHP but AU3 is hard.. :)

$pk1_filename   =   "Finfo.pk1"
$file           =   FileOpen($pk1_filename,1)
$pk1_lines      =   _FileCountLines($pk1_filename)

For $number = 1 To $pk1_lines-1                 ;; FileLine starts with 1
    $pk1_line   =   FileReadLine($file,$number) ;; FileReadLine 1
    $pk1_array  =   StringSplit($pk1_line,"\")  ;; Split into \ (4 splits)
    If IsArray($pk1_array) Then $pk1_name   =   UBound($pk1_array,0)
    
;GUICtrlCreateMenuitem($pk1_name,$item2)
    MsgBox(0,"Title",$pk1_name)                 ;; Show UBound
;Array $menuID[$number] = menuitem/load name
Next

This is my code, the thing is, it says an error.

This is what i want to get with the code:

I have already a code that opens a file Dialog and asks for a file. When selecting a file it automatically writes this:

line1 = C:\Program Files\Documents and Settings\Myfile.txt

I want to get the end of that line (Myfile.txt) and show it with an Control Menu Item. And on Press it must load the file.

Can anyone help me with that? please, i'm a nub :(

Well Cya

- ImMenSe

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I seen some errors in your code, including the missing #include file. Try This:

#include <File.au3>

$pk1_filename   =   "Finfo.pk1"
$file           =   FileOpen($pk1_filename,1)
$pk1_lines      =   _FileCountLines($pk1_filename)

For $number = 1 To $pk1_lines step -1           ;; FileLine starts with 1
    $pk1_line   =   FileReadLine($pk1_filename,$number);; FileReadLine 1
    $pk1_array  =   StringSplit($pk1_line,"\");; Split into \ (4 splits)
    If IsArray($pk1_array) Then $pk1_name   =   UBound($pk1_array)
    
;GUICtrlCreateMenuitem($pk1_name,$item2)
    MsgBox(0,"Title",$pk1_name)         ;; Show UBound
;Array $menuID[$number] = menuitem/load name
Next

hope this helps,

Nomad

Edited by Nomad

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I know some things are missing :), i copy pasted only the bugged part :(

AND WAUW!!! it worked :D thank you so much,

immense

Edited by Immense

Share this post


Link to post
Share on other sites

No problem, I just noticed a small error in the script I gave you though..

The -1 after the step should be a 1. Since it starts at 1, you want it to count positive up to the number of lines, not backwards to the negative side... my mistake. :)


Share this post


Link to post
Share on other sites

I know that :( i've changed the - into + And it works perfectly!

thanks again :)

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