Jump to content

_FileReadToArray not working


Recommended Posts

Func LoadRoomNumbers() ; load text file into $RoomArray, if not present the macro will quit, text file directory is on line 40.
    _FileReadToArray("C:\Program Files (x86)\AutoIt3\LoadRoomNumbers\roomnumbs.txt", $RoomArray)
    If @error Then
        MsgBox(0, 'Fatal Error', 'File Not Found Error, - File NOT read to ARRAY', 3)
        Exit
    EndIf
    ToolTip($RoomArray[0],0,0)
EndFunc

roomnumbs.txt

NAE-02_CALIT.N2-1.RM-1601C.7-1VAV1-1,1601C
NAE-02_CALIT.N2-1.RM-1601F.7-1VAV1-2,1601F
NAE-02_CALIT.N2-1.RM-1601H.7-1VAV1-3,1601H
NAE-02_CALIT.N2-1.RM-1602A.1-1VAV1-27,1602A
NAE-02_CALIT.N2-1.RM-1604A.1-1VAV1-28,1604A
NAE-02_CALIT.N2-1.RM-1604B.1-1VAV1-24,1604B
NAE-02_CALIT.N2-1.RM-1604C.1-1VAV1-23,1604C
NAE-02_CALIT.N2-1.RM-1604D.1-1VAV1-26,1604D
NAE-02_CALIT.N2-1.RM-1604E.1-1VAV1-25,1604E
NAE-02_CALIT.N2-1.RM-1606.1-1VAV1-29,1606
NAE-02_CALIT.N2-1.RM-1607.1-1VAV1-44,1607
NAE-02_CALIT.N2-1.RM-1608.1-1VAV1-37,1608
NAE-02_CALIT.N2-1.RM-1608A.1-1VAV1-40,1608A
NAE-02_CALIT.N2-1.RM-1608B.1-1VAV1-39,1608B
NAE-02_CALIT.N2-1.RM-1609.1-1VAV1-45,1609
NAE-02_CALIT.N2-1.RM-1611.1-1VAV1-46,1611
NAE-02_CALIT.N2-1.RM-1613.1-1VAV1-47,1613

Well I need to work with these values but the tooltip says 17 when it's suppose to say (I think) NAE-02_CALIT.N2-1.RM-1601C.7-1VAV1-1,1601C; any advice?

\

Link to comment
Share on other sites

Your text file contains 17 lines, from the help file:

$aArray[0] will contain the number of records read into the array.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The way you're doing it is correct, you just need to be aware that your information from the file starts at 1 and not 0, and code your script accordingly.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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...