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).
Hi SLThe 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 regardsQuek