/* * GREPPER * * GREPPER is an external function that uses the Unix 'grep' command * to pull a single item out of a file rather than the entire line. * * The syntax of the GREPPER function is * * grepper("filename","token") * * where "filename" is the file to be searched and "token" is the * front end of the line being searched. * * GREPPER searches "filename" until a line of the format * * token: value * * is found. The single value following the token is returned. * * For example, if you have a file 'test' containing a line * such as the following * * Name: John Doe Phone: 123-456-7890 * * and you use the grepper function * * grepper("test","Name") * * 'John' is returned. * * If you use the grepper function * * grepper("test","Phone") * * '123-456-7890' is returned. * */ parse arg filename,token rc = popen('grep "'||token||':"' filename ' 2> /dev/null') if rc<>0 | queued()=0 then value = "missing" else if queued()>1 then value = "duplicates found" else parse pull (token) ":" value . return strip(value)