Tcl/keep CT automated test script instance 5-read a row from the file

Source: Internet
Author: User
Code As shown in the following figure, it is relatively simple and will not be analyzed. For more information about how to call an instance, see Article .

#*************************************** *********
# Get a line from file, skip blank lines and
# Comment lines, return the reading line in
# Parameter 'line '.
#
# @ Params
# FD-file FD
# Line-var used to return the line
#
# @ Return
# Return 1 if read successfully, otherwise 0
#*************************************** *********
Proc Getline {FD line }{
Upvar $ line ln

# Read a line from Fd
While {[set linelen [gets $ FD ln]> = 0 }{
# Blank line
If {$ linelen = 0} continue
 
# Trim whitespace
Set ln [String trim $ ln]
If {[String Length $ ln] = 0} continue

# Skip comment
If {[String index $ ln 0] = "#"} continue

# Success
Return 1
}

Return 0
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.