Jump to content

Loading a File via a .txt file


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
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. :)

Link to comment
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
 Share

  • Recently Browsing   0 members

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