🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Check list and file reading.

User: "Jouher_20929"
Altair Community Member
Updated by Jouher_20929

I have written a code to create checklist to read Id and names from a text file.


{BEGIN LEGEND}
 Entity #        Title
        1     abc                                                           
        2     efs                                                                
        3     afdsf                                                                     
        4     xzcH                                                                       
        5     sdsafd                                                                  
        6     wqerwf                                                                  
 

During file reading I want to skip first two lines and take lines from 3 to 10. What change should be made in the code?

Similarly, in the checklist, when I tick and press OK, the corresponding ID should be stored in a variable. WHat should I do?

 

The code is given below!!!!!!!!!!!!!!!!

 

 

 

 

 

 


$w hide apply;

set recess [$w recess]

 


proc ::texample::OnSelect {W S c} {

    puts [info level 0]

}

 

hwtk::selectlist $recess.sl -stripes 1 -selectmode multiple -selectcommand '::texample::OnSelect %W %S %c'

pack $recess.sl -fill both -expand true;

$recess.sl columnadd id -text Id

$recess.sl columnadd entities -text 'Section Name'

#####################

set fileName [tk_getOpenFile]
set fp [open $fileName r]
set ::lines [split [read $fp] '\n']


set i 0

foreach line $::lines {

set ID [string range $line 7 8]
set NM [string range $line 14 20]

$recess.sl rowadd row$i -values


  1. incr i

    }
    close $fp;                         

}

$w post

Find more posts tagged with