Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

FileWrite using variable file names

$
0
0

Here is what I have attempted to do.

I have a populated Listview where one of the columns contains various names and those names are used as file names when i write the listview text lines to a file. In this code $myVar[5] represents the variable file names.

So I am reading the Listview, assigning the file names and then attempting to write the data from all the columns in each line.  The file names in the List are not sequential. So all the lines for say $myVar[5] = "XYZ" will go to its own file and $myVar[5] = "ABC" to its own file. Finally a totally separate file contains all "XYZ" and all "ABC".

I need to use the over write mode, since I can edit the Listview.  I can see the FileWrite as written won't work the way I want since the handle doesn't change.  This is what I need help learning.

 

Thanks

Hobbyist

AutoIt         
    case $ListSave = $list5         for $i = 0 to $savecount  -1         $savecounterx = _GUICtrlListView_GetItemTextString ( $ListSave,$i  )         $savecounterx = $savecounterx & "|"         $myVar = StringSplit($savecounterx , "|")                 For $k = 1 To 5         Next         $savecounterx  =  '"'&$myVar[1]&'"'&","&$myVar[3]&","&'"'&$myVar[2]&'"'&","&","& '"'&$myVar[5]&'"'           $sFileStuff = ("c:\MySuff\01 MyLog\" & _MyMonth($sMon) & ".csv")         $sFileSave = ("c:\MySuff\"&$myVar[5]  &"\MyLog\" & _MyMonth($sMon) & ".csv")             If FileExists($sFileSave) then               $hFileOpen2 = FileOpen ($sFileSave, 2)                         EndIf              If FileExists($sFileStuff) then                            $hFileOpen = FileOpen ($sFileStuff,2)                     EndIf Next     GUICtrlRead ( $ListSave) for $i = 0 to $savecount  -1         $savecounterx = _GUICtrlListView_GetItemTextString ( $ListSave,$i  )         $myVar = StringSplit($savecounterx , "|")         For $k = 1 To 5         Next                 $savecounterx  =  '"'&$myVar[1]&'"'&","&$myVar[3]&","&'"'&$myVar[2]&'"'&"," &","& '"'&$myVar[5]&'"'                 FILEWRITE($hFileOpen  ,  $savecounterx  &@crlf )                 FILEWRITE($hFileOpen2,  $savecounterx  &@crlf ) Next                 FileClose ($hFileOpen)                 FileClose ($hFileOpen2)     EndSelect

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>