Home > Community > Forums > Custom IC SKILL > help - search a word in a file using SKILL

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 help - search a word in a file using SKILL 

Last post Fri, Jan 8 2010 10:54 AM by Quek. 1 replies.
Started by llobak 08 Jan 2010 07:27 AM. Topic has 1 replies and 2666 views
Page 1 of 1 (2 items)
Sort Posts:
  • Fri, Jan 8 2010 7:27 AM

    • llobak
    • Top 500 Contributor
    • Joined on Fri, Aug 21 2009
    • Melaka, Melaka
    • Posts 19
    • Points 320
    help - search a word in a file using SKILL Reply

    Hi,

     This is what I'm trying to do using SKILL:

    - open up a file

    - search a certain keyword in the file( example: i would like to search the keywork "cell height = 123" so that i can extract the value 123 from the file)

     Can anyone provide me with some help on how to achieve what i hope to do? I'm facing problem because the file that i read from does not have a fix format( this mean that the keyword that i want to search for can be anywhere in the file).

    Thanks,

    SL

    • Post Points: 20
  • Fri, Jan 8 2010 10:54 AM

    • Quek
    • Top 10 Contributor
    • Joined on Wed, Oct 14 2009
    • Singapore, 00-SG
    • Posts 1,051
    • Points 15,990
    Re: help - search a word in a file using SKILL Reply

    Hi SL

    The following skillscript should be able to solve your problem:

    procedure( CCSreadFile(myFile pattern)
       prog( (inPort inLine inLineList)
          inPort=infile(myFile)
          unless( inPort
             printf("%s cannot be opened\n" myFile)
             return(t)
          ) ;unless

          while( gets(inLine inPort)
             if(rexMatchp(pattern inLine) then
                inLine=index(inLine pattern)
                inLineList=parseString(inLine "= ")
                return(nth(2 inLineList))
             ) ;if
          ) ;while
          close(inPort)
          inPort=nil
      ) ;prog
    ) ;procedure

    Load and execute it in ciw using:
    load "readfile.il"
    CCSreadFile("myFile.txt" "cell height")

    It will return the value of cell height. I assumed that the words "cell height = 123" appears only once in the line.

    Best regards
    Quek

    • Post Points: 5
Page 1 of 1 (2 items)
Sort Posts:
Started by llobak at 08 Jan 2010 07:27 AM. Topic has 1 replies.