Jump to content

Add to array


Recommended Posts

Hi all,

Can anyone help me on this .

Currently i'm write to .txt file. How to change it to Array.

For $i = 0 To $Num
 $open = FileOpen("C:\temp\recipe.txt",1)
 $MYEditText = _GUICtrlListBox_ClickItem ($LHandle,$i) 
 $MyWantedText1 = ControlGetText($Handle,"","")
 $MyWantedText1 = StringStripWS($MyWantedText1, 1)
 $MyWantedText1 = StringStripWS($MyWantedText1, 2)
 $file = FileWrite($open,$MyWantedText1 & @CRLF) ;(Write test at .txt)
 FileClose($open)
 Next

Thanks

Link to comment
Share on other sites

@Rammanan
Before digging into your request, some comments are a must.

For $i = 0 To $Num
 $open = FileOpen("C:\temp\recipe.txt",1) ; You could open the file just once, instead of opening it for each $i you have
 $MYEditText = _GUICtrlListBox_ClickItem ($LHandle,$i) ; The variable MYEditText doesn't contain anything, since the function you are calling has no return value
 $MyWantedText1 = ControlGetText($Handle,"","")
 $MyWantedText1 = StringStripWS($MyWantedText1, 1) ; You could combine this line and the one below
 $MyWantedText1 = StringStripWS($MyWantedText1, 2)
 $file = FileWrite($open,$MyWantedText1 & @CRLF) ;(Write test at .txt) ; If you are trying to write just one line, use FileWriteLine()
 FileClose($open) ; Same discussion of above
 Next

So, now, if you want to write that text in an array, just use _ArrayAdd() and you're done :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

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