home *** CD-ROM | disk | FTP | other *** search
- ********************
-
- FUNCTION Modi_auto
-
- PARAMETERS _a, _b
-
- * _a is the string to search for in the AUTOEXEC.BAT
- * is the string to replace that entire line that is found
- * if !FOUND(), then add the line to the file
- * _b is the drive to look for AUTOEXEC.BAT
-
- IF PCOUNT() = 1
- _b = "C:"
- ENDIF
-
- IF TYPE("_a") + TYPE("_b") != "CC"
- RETURN(.F.)
- ELSEIF LEN(_b) != 2
- RETURN(.F.)
- ELSEIF !FILE(_b + "\AUTOEXEC.BAT")
- RETURN(.F.)
- ENDIF
-
- PRIVATE _temp, _search, _c, _passback
-
- _temp = MEMOREAD(_b + "\AUTOEXEC.BAT")
-
- MEMOWRIT(_b + "\AUTOEXEC.SST", _temp)
-
- _search = UPPER(Parsing(@_a))
- IF EMPTY(Occurence(_search, _temp))
- * Just append the line to the end of the file
- MEMOWRIT(_b + "\AUTOEXEC.BAT", STRTRAN(TRIM(_temp) + _a, ;
- CHR(13)+CHR(10)+CHR(13)+CHR(10), CHR(13)+CHR(10)))
- _passback = .T.
- ELSE
- * first, check to see if the line contents are the same with the
- * contents of _a and if so, just return (.T.) without writing back
- * the file. Otherwise, write out a new file by replacing the line
- * with the contents of _a
- _c = TRIM(Parsing(STRTRAN(Occur_at(_search, UPPER(_temp) ), ;
- CHR(13)+CHR(10), "|"), "|"))
- IF _c != TRIM(_a)
- _temp = STRTRAN(UPPER(_temp), UPPER(_c), UPPER(_a))
- MEMOWRIT(_b + "\AUTOEXEC.BAT", STRTRAN(TRIM(_temp), ;
- CHR(13)+CHR(10)+CHR(13)+CHR(10), CHR(13)+CHR(10)) )
- _passback = .T.
- ELSE
- _passback = .F.
- ENDIF
- ENDIF
- RETURN(_passback)
-
- * End of File
-
-