Library Software FAQ> Auto-Cataloging, Web Search> How to customize the web search, scripting language.

Related software (Read/Download) :
Library Software Solutions
Church Library Organizer Pro

Question/Topic: How to customize the web search (scripting language)?

Syntax of the scripting language. General rules:

  • first line should contain the declaration of variables, e.g.
    def #title, #author, #isbn, #publisher
  • second line should contain the declaration of private variables, e.g.
    def #n, #count
  • each variable name should start from # character
  • each function name should start from $ character
  • function parameters are enclosed in brackets, e.g.
    #title=$rtrim(#title)
    #title=$copyuntil(<)
  • a function parameter is either a variable or a string
  • a function returns the result always as a string
  • a function name is always in lower case

List of all functions:

  • $find(string) - find text in the source file and the cursor is set right after it
  • $uppercase(string) - convert a string to upper case
  • $lowercase(string) - convert a string to lower case
  • $gotop - go to beginning of the source file
  • $goend - go to end of the source file
  • $copyuntil(string) - the result is text from the current cursor position (e.g. set by $find) until the "string"; the cursor is set immediately after "string" returned
  • $copyuntilnewln - the result is text from the current cursor position until the end of the line; the cursor is set at the beginning of the next line. (removes all spaces and tabs from the beginning and end of the result)
  • $copyuntilnewln1 - the result is text from the current cursor position until the end of the line; the cursor is set at the beginning of the next line. (does not removes spaces and tabs)
  • $copycount(count) - the result is text from the current cursor position that has the length of count characters; the cursor is position after the last character returned.
  • $addnum(num1,num2) the result is the sum of two numbers; num1 and num2 can be integers in a string format or they can be variables containing integers.
  • $subtractnum(num1,num2) the result is the subraction of two numbers; num1 and num2 can be integers in a string format or they can be variables containing integers.
  • $struntil(string, str) - the result is text from the str string until the "string"
  • $strfromuntil(from_str, until_str, str) - the result is text from the str starting from from_str string until until_str
  • $strfromuntil2(from_str, until_str1, until_str2, str) - the result is text from the str starting from from_str string until until_str1 or until until_str2; if from_str is not found the result is an empty string (the same is true if both until_str1 and until_str2 not found);
  • $assignhex(hexvalue) - returns a HEX string, the string can be up to 8 chracters long and the result is up to 4 characters (bytes) long; for example '1E' converts to 1 character (#30).
  • $strdelmarc(subflddel,flddel,replacestr,str) - in string str replace with replacestr all occurrences of string subflddel plus 1 character until flddel; also, delete string flddel
  • $skiptonewline - skip to the next line
  • $skipby(count) - skip count characters from the current cursor position;
  • $rtrim(string) - remove spaces and tabs from the end of the string
  • $ltrim(string) - remove spaces and tabs from the beginning of the string
  • $exit - exit the script
  • $length(string) - return the number of characters in the string; the result has the string type
  • $substr(string,from,count) - return a substring of string beginning at from position; the length of the substring is specified by count; from and count can be numbers or variables e.g. $substr(#mytext,1,#var1)
  • $lastfound(0) - if the result is '1' the last $find function found the string, if the result is '0' the last $find function failed to find the string
  • $delstring(string,#param) - delete a substring from a variable
  • $strdelhtml(string) - delete html tags from a string variable
  • $replacestr(withstr,whatstr,string) - replaces the first occurence of whatstring in string with withstring
  • $replaceallstr(withstr, whatstr,string) - replaces all occurences of whatstring in string with withstring
  • $findstr(what,string) - if what is found in string the result is the index of the first character found; the result is 0 if the string is not found
  • $replacespecial(string) - replace html codes with special characters
    &amp;  =  &
    &gt;  =  >
    &lt;  =  <
  • $addstring(str1,str2) - the result is a string: str1 + str2
  • $break - break the script and do not close the input file; it is useful when you want to extract multiple records; when Process can be called in a loop until the end of file is reached or $finish function is called in the script.
  • $finduntil(string) - all following $find functions will stop searching on the first occurence of string; the cursor will be set just before this string
  • $eof - returns '1' if end of the text file
  • $setbookmark - save the current location in the source file (current line and character index)
  • $gotobookmark - go to the previously saved bookmark
  • $clearbookmark - clear previously saved bookmark
  • $date - returns the system(computer) date (e.g. #date=$date)
  • $time - returns the system(computer) time (e.g. #time=$time)
  • $writestr_out_file(string) - writes a string to OutputFile; (only used in Convert Marc File procedure)
  • $writeln_out_file - writes new line character to OutputFile; (only used in Convert Marc File procedure)

Assignment:

  • assignment: you can assign the result of a function to a variable, e.g.
    #title=$rtrim(#title)
  • empty string assignment: "" means empty string, e.g.:
    #str1="" (use this in the script)
    {Title}="" (use this in the mapping window)

New Line:

  • declare a local variable. e.g.: #newline
  • assign $newline function to your local variable. e.g.:
    #newln=$newline
  • Then, you can use #newln variable in any function. e.g.:
    #subjects=$addstring(#subjects,#newln)

If statement.

  • it has the following format :
    if (expression)
    statements executed when expression is true
    else
    statements executed when expression is false
    endif
  • the if expression can use: =,<,>,<> operators
    example if statement:
    if (#left=John)
    #text=$copyuntil(&)
    $gotop
    else
    #text=$copyuntil(a#)
    endif


While .. endwhile statement.


  • $find(string)
    while ($lastfound(0)=1)
    statements executed when expression is true
    $find(string)
    endwhile

Comments

Use // at the beginning of the line to include a comment in your script file.


Copyright © PrimaSoft PC, Inc. All rights reserved.