If Search()

IF Search() searches a text file for the occurrence of a specific text string. It skips the occurrence of the string if it is on a line beginning with skipstring. It searches within the section bracketed by search-after-string and search-before-string. When found, the function returns a true condition for use in the IF statement and assigns the variable $SEARCH$ with the numeric value of the line number in which the string was found. It also assigns values to $LEFT$ and $RIGHT$ variables. These two variables contain the text that appears to the left and the right of the string. Most frequently, this function is used with the ADDTEXT command to edit a line in an existing text file.

Example 1:

IF Search("zipcode.exe","c:\Autoexec.bat")

ADDTEXT: "$LEFT$zipcode.exe -USA$RIGHT$", "c:\Autoexec.bat", "$SEARCH$", replace

ENDIF

This example searches the text file C:\Autoexec.bat for the string Zipcode.exe. If it is found, then the parameter -USA is inserted into the line immediately after Zipcode.exe. Any other text in that line, either in front of or following Zipcode.exe is maintained.

Example 2:

ASK1: "your name", prompt="Please enter your name:"

IF Search("Sir","$sourcedir$\readme.txt")

ADDTEXT: "$LEFT$$ASK1$$RIGHT$", "$defaultdir$\readme.txt", "$SEARCH$", replace

ENDIF

This example prompts the user for a name and assigns the value to $ASK1$. The SEARCH function searches the Readme.txt file that is on the source drive for Sir. The line number in which Sir appears in this text file is assigned to the variable $SEARCH$. The ADDTEXT locates that line and replaces it with the user's name (as stored in $ASK1$). It restores whatever came before Sir by using $LEFT$, and whatever was to the right of Sir by using $RIGHT$.

Example 3:

IF SEARCH("Drive=","$windir$\pcloan.ini", ";", begin="[Network]", end="[end]")

ADDTEXT: "$LEFT$Drive1=$RIGHT$", "$windir$\pcloan.ini", "$SEARCH$", replace

ENDIF

You can also replace a line in a specific section in a .ini file. This example searches in the section labeled Network for the occurrence of Drive= and substitutes the value Drive1. Note that this example skips any line starting with ;.


Объявления:
    • Https://kok.one

      https://kok.one купить шкафы холодильные Polair.

      kok.one