PRODUCT






Home









Free Download








Installation Instructions





FAQ





FAQ








Ask A Question





LEARN SCRIPTING





Overview








Lesson 1








2


3


4


5








Exam





SAMPLE SCRIPTS





Computer








Internet








Administrators








Developers








Data








Miscellaneous





HELP / DOCUMENTATION





Commands








Automated Internet








Automated Editors








Sample Scripts








Precompiled Functions








System Features






  Sample Script - SS_FindStr

( Some of the sample scripts may not be reproduced correctly in html because those scripts, especially web-related scripts, have html tags such as < tr > in their code.

For an accurate, copy-and-paste'able text version of this script, see SS_FindStr.txt . )



#####################################################################
# SCRIPT: SS_FindStr
#
# This script finds a string instance in files whose names match
# a given criterion in a given directory.
#
# The criterion for file names is assigned using FVA (Forward Variable Assignment)
# for str variable $files. The value of $files is of form
# "*.html", "*.js", "*.cpp", "*.h", etc.
#
# The directory name is assigned using FVA
# for str variable $dir. The value of $dir is of form
# "C:/ABC/DEF", ".", etc.
#
# The string being sought is assigned using FVA
# for str variable $str. The value of $str is of form
# "abc", "Copyright", etc.
#
# The start line is assigned using FVA for str variable $from. The
# value is of the form "1", "2", etc. If no value supplied, "1" is assumed.
#
# The end line is assigned using FVA for int variable $to. The
# value is of the form "1", "100", etc. If no value is supplied, "l" (last line) is assumed.
#
# Note that $from and $to are str variables. If you are passing int values, use the makestr() function
# as follows.
# from(makestr(int(1))) to(makestr(int(5)))
#
# This script can be stored and edited as necessary, in a text file
# called SS_FindStr.txt in a directory in your $path. The script can then be called as
#
# script SS_FindStr.txt files("*.cpp") dir("C:/mydir") str("abc") from("1") to("5")
#
#
#####################################################################

# Declare FVA variables.
var str files
var str dir
var str str # The first str is the variable type, the second str is the variable name.
var str from
var str to

# Get the list of files in variable fileList.
var str fileList
script "SS_ListFiles.txt" dir($dir) files($files) > $fileList

# We will store the name of one file in $file.
var str file

# Go thru the $fileList one by one file.
while ($fileList <> "")
do
# Extract the next file.
lex "1" $fileList > $file

# Check if this is a flat file. Directories will
# produce error in the repro command.
af $file > null # We don't want to see the output.
# We only want to set the $ftype variable.
if ($ftype == "f")
do
# Yes, this is a flat file.

echo "File:\t" $file

scr SS_FindLinesStr.txt str($str) file($file) from($from) to($to)

done
endif

done

2008-2014, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterMobile, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com. Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.