Jump to content

array display


ussr
 Share

Recommended Posts

#include <file.au3>
#Include <Array.au3>
HotKeySet( "{ESC}", "end" )
Func end()
    Exit 0
EndFunc
$file = FileOpen("v.txt", 0)
If $file = -1 Then
    Exit
EndIf
If $file = -1 Then
    Exit
EndIf
Dim $file
If Not _FileReadToArray("v.txt",$file) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $file[0]
Next
_ArrayDisplay($file)
FileClose($file)

The script is working but When I add or change in the v.txt file the new value is not displayed.

Could you help me guys .

Link to comment
Share on other sites

$file is the handle returned by FileOpen(), then you wiped out the value when you used DIM to declare it again, so the file is open but you don't have the handle anymore, and _FileReadToArray() can't reopen the file. Don't confuse the issue by reusing your variables like that:

#include <file.au3>
#Include <Array.au3>

Global $sFile = "v.txt", $aFile[1]
Global $hFile = FileOpen($hFile, 0)
If $file = -1 Then
    Exit
EndIf
If Not _FileReadToArray($hFile, $aFile) Then
   MsgBox(4096,"Error", " Error reading log " & $sFile & " to Array     error:" & @error)
   Exit
EndIf

_ArrayDisplay($aFile)
FileClose($hFile)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Unless you're constantly reading the contents of the v.txt file you're only going to get the contents the first time you read in the file, it's not going to monitor it for changes the way you've written it.

@PsaltyDS

_FileReadToArray can't use a file handle, it needs the actual file path and filename. I believe he was using the fileopen as a means of checking to see if the file is there.

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 script is working but When I add or change in the v.txt file the new value is not displayed.

Could you help me guys .

_ArrayDisplay will pause the script untill you close that win, to display new data you need to...

close _ArrayDisplay win,

to recall _FileReadToArray one more to reread new entered data and

call _ArrayDisplay to openup one more time to display it

maby your need something diffrent like GUI commands, GUICtrlCreateListView for example, instead of _ArrayDisplay?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

@PsaltyDS

_FileReadToArray can't use a file handle, it needs the actual file path and filename.

Oops. I thought I remembered those being updated to accept handles, so you could FileOpen() in specific non-standard modes. My bad.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Oops. I thought I remembered those being updated to accept handles, so you could FileOpen() in specific non-standard modes. My bad.

:mellow:

I took a look at the File.au3 file and the first command in the _FileReadToArray function is a FileOpen command, which is probably why it has to have a filename and path.

Which, coincidentally, means that there's no reason to use a FileOpen before calling the _FileReadToArray function, because all you'd need to do is look at the return values of it to see if the file is there or not, or at least whether it can be opened or not.

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

Look at _FileWriteFromArray() code in the UDF. It will take a file handle for $File so you can open it in an alternate Unicode format, or you can pass the string path and it will FileOpen() for you in default format. I just thought I remembered that capability being spread to more of the functions in File.au3 than it really was. The wonders of the aging brain...

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...