KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Empty Row

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
magicmajid
KiXforms Dabbler
KiXforms Dabbler


Joined: 14 Mar 2008
Posts: 8

PostPosted: Tue May 06, 2008 2:41 pm    Post subject: Empty Row Reply with quote

Hello,

I have made a little program that reads a config file and then puts everything in a listview.

My problem is that the in my listview there is one empty line at the beginning and the last line of the config file is missing.

But when i display everything in my dos box it shows al the rows are taken from the config file.

Someone a idea?
Code:

Function Config_uitlezen()

If Not @LOGONMODE
   Break ON
EndIf

Dim $SO
$SO = SetOption("Explicit","Off")
$SO = SetOption("NoMacrosInStrings","Off")
$SO = SetOption("NoVarsInStrings","Off")
$SO = SetOption("WrapAtEOL","Off")

Dim $Handle1, $File1, $Delimiter, $Line, $get_move_copy, $get_source, $get_destination,$get_extention_filter, $get_extentions, $get_filename,$get_static_dynamic, $get_label, $get_path,$get_interval, $i
$File1 = "C:\kix32\Filemover\config.ini"
$Handle1 = FreeFileHandle()
$Delimiter = "|"

$i = -1

;Hieronder worden alle waardes uit het bestand uitgelezen en in een array geplaatst.
;Try to open the file for read
If Open($handle1,$File1,2) = 0
   ;Read line per line until error indicates there are no lines anymore
   $Line = Split(ReadLine($Handle1),$Delimiter)
   While @ERROR = 0
      If UBound($Line) > 0
         $i = $i + 1
         ? $i
         ReDim Preserve $get_move_copy[$i], Preserve $get_source[$i], Preserve $get_destination[$i], Preserve $get_extention_filter[$i], Preserve $get_extentions[$i], Preserve $get_filename[$i], Preserve $get_static_dynamic[$i], Preserve $get_label[$i], Preserve $get_path[$i], Preserve $get_interval[$i]
         $get_move_copy[$i] = $Line[0]
         ;? $Line[0]
         $get_source[$i] = $Line[1]
         ;? $Line[1]
         $get_destination[$i] = $Line[2]
         ;? $Line[2]
         $get_extention_filter[$i] = $Line[3]
         ;? $Line[3]
         $get_extentions[$i] = $Line[4]
         ;? $Line[4]
         $get_filename[$i] = $Line[5]
         ;? $Line[5]
         $get_static_dynamic[$i] = $Line[6]
         ;? $Line[6]
         $get_label[$i] = $Line[7]
         ;? $Line[7]
         $get_path[$i] = $Line[8]
         ;? $Line[8]
         $get_interval[$i] = $Line[9]
         ;? $Line[9];
      EndIf
      $Line = Split(ReadLine($Handle1),$Delimiter)
   Loop
   $SO = Close($Handle1)
EndIf

; Hieronder worden al die waardes die zijn uitgelezen in de listview gestopt.
If $i => 0
   For $j = 0 to $i
      
      $item = $commando_lijst.Items.Add               
      $item.Subitems(0).text = $LVitem_Move_Copy
      $LVitem_Move_Copy = $get_move_copy[$j]
      $item.Subitems(1).text = $LVitem_source
      $LVitem_source = $get_source[$j]
      $item.Subitems(2).text = $LVitem_destination
      $LVitem_destination = $get_destination[$j]
      $item.Subitems(3).text = $LVitem_extention_filter
      $LVitem_extention_filter = $get_extention_filter[$j]
      $item.Subitems(4).text = $LVitem_extentions
      $LVitem_extentions = $get_extentions[$j]
      $item.Subitems(5).text = $LVitem_filename
      $LVitem_filename = $get_filename[$j]
      $item.Subitems(6).text = $LVitem_static_dynamic
      $LVitem_static_dynamic = $get_static_dynamic[$j]
      $item.Subitems(7).text = $LVitem_label
      $LVitem_label = $get_label[$j]   
      $item.Subitems(8).text = $LVitem_label_path
      $LVitem_label_path = $get_path[$j]
      $item.Subitems(9).text = $LVitem_interval
      $LVitem_interval = $get_interval[$j]
      ? "komt ie" + $LVitem_Move_Copy+" "+$LVitem_source+" "+$LVitem_destination+" "+$LVitem_extention_filter+" "+$LVitem_extentions+" "+$LVitem_filename+" "+$LVitem_static_dynamic+" "+$LVitem_label+" "+$LVitem_label_path+" "+$LVitem_interval
    
   Next
EndIf
EndFunction
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Tue May 06, 2008 6:18 pm    Post subject: Reply with quote

Hi magicmajid,

The reason why you see an empty row in the beginning and the last is because of this for loop.

Code:

   For $j = 0 to $i
     
      $item = $commando_lijst.Items.Add               
      $item.Subitems(0).text = $LVitem_Move_Copy
      $LVitem_Move_Copy = $get_move_copy[$j]
      $item.Subitems(1).text = $LVitem_source
      $LVitem_source = $get_source[$j]
      $item.Subitems(2).text = $LVitem_destination
      $LVitem_destination = $get_destination[$j]
      $item.Subitems(3).text = $LVitem_extention_filter
      $LVitem_extention_filter = $get_extention_filter[$j]
      $item.Subitems(4).text = $LVitem_extentions
      $LVitem_extentions = $get_extentions[$j]
      $item.Subitems(5).text = $LVitem_filename
      $LVitem_filename = $get_filename[$j]
      $item.Subitems(6).text = $LVitem_static_dynamic
      $LVitem_static_dynamic = $get_static_dynamic[$j]
      $item.Subitems(7).text = $LVitem_label
      $LVitem_label = $get_label[$j]   
      $item.Subitems(8).text = $LVitem_label_path
      $LVitem_label_path = $get_path[$j]
      $item.Subitems(9).text = $LVitem_interval
      $LVitem_interval = $get_interval[$j]
      ? "komt ie" + $LVitem_Move_Copy+" "+$LVitem_source+" "+$LVitem_destination+" "+$LVitem_extention_filter+" "+$LVitem_extentions+" "+$LVitem_filename+" "+$LVitem_static_dynamic+" "+$LVitem_label+" "+$LVitem_label_path+" "+$LVitem_interval
   
   Next


You are setting the listview row to variables that initially have no values (e.g., $LVitem_Move_Copy, $LVitem_source, $LVitem_*). I'm not sure what those variables are used for, but if you change the function to this, it should work

Code:

      For $j = 0 to $i
         $item = $commando_lijst.Items.Add
         $item.Subitems(0).text = $get_move_copy[$j]
         $LVitem_Move_Copy = $get_move_copy[$j]
         $item.Subitems(1).text = $get_source[$j]
         $LVitem_source = $get_source[$j]
         $item.Subitems(2).text = $get_destination[$j]
         $LVitem_destination = $get_destination[$j]
         $item.Subitems(3).text = $get_extention_filter[$j]
         $LVitem_extention_filter = $get_extention_filter[$j]
         $item.Subitems(4).text = $get_extentions[$j]
         $LVitem_extentions = $get_extentions[$j]
         $item.Subitems(5).text = $get_filename[$j]
         $LVitem_filename = $get_filename[$j]
         $item.Subitems(6).text = $get_static_dynamic[$j]
         $LVitem_static_dynamic = $get_static_dynamic[$j]
         $item.Subitems(7).text = $get_label[$j]
         $LVitem_label = $get_label[$j]   
         $item.Subitems(8).text = $get_path[$j]
         $LVitem_label_path = $get_path[$j]
         $item.Subitems(9).text = $get_interval[$j]
         $LVitem_interval = $get_interval[$j]
         ? "komt ie" + $LVitem_Move_Copy+" "+$LVitem_source+" "+$LVitem_destination+" "+$LVitem_extention_filter+" "+$LVitem_extentions+" "+$LVitem_filename+" "+$LVitem_static_dynamic+" "+$LVitem_label+" "+$LVitem_label_path+" "+$LVitem_interval
         
      Next
Back to top
View user's profile Send private message
magicmajid
KiXforms Dabbler
KiXforms Dabbler


Joined: 14 Mar 2008
Posts: 8

PostPosted: Wed May 07, 2008 7:09 am    Post subject: Reply with quote

Hi there pearly,

Thanx it works.
I understand what it was now. Didn't think the problem would come from that.

But thanks a lot!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group