home *** CD-ROM | disk | FTP | other *** search
- *⌐░⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐┤
- *⌐ª Program: LOCKDB.PRG ⌐ª
- *⌐ª Function: ╩╣╙├ LLIO ║»╩²╨▐╕─╩²╛▌┐Γ╡─┐¬═╖╡─╡┌╥╗╕÷╫╓╜┌, ╥╘▒ú╗ñ ⌐ª
- *⌐ª ╩²╛▌┐Γ╡─╖╢└². ⌐ª
- *⌐ª Usage: =LOCKDB("Database name") ⌐ª
- *⌐╕⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐ñ⌐╝
- FUNCTION lockdb
- PARAMETERS file_name
- PRIVATE file_name, file_alias, handle, keybyte
-
- IF AT(".",file_name) = 0
- * ╚τ╣√├╗╙╨┤½╗╪╩²╛▌┐Γ║≤╫║├√ .DBF ╡─┤ª└φ
- file_alias = file_name
- file_name = file_name + ".DBF"
- ELSE
- file_alias = SUBSTR(file_name,1,AT(".",file_name)-1)
- ENDIF
-
- IF USED(file_alias)
- WAIT "LOCKDB() ╬▐╖¿╨▐╕─╥╤┤≥┐¬╩²╛▌┐Γ┐¬═╖╡─╡┌╥╗╕÷╫╓╜┌. "+;
- "╟δ╣╪▒╒╩²╛▌┐Γ " + upper(file_alias) + " ║≤╘┘╩╘ ! " WINDOW
- RETURN(.F.)
- ENDIF
-
- handle = FOPEN(file_name,2)
-
- IF handle = -1
- = WRONG("LOCKDB() ╬▐╖¿│╔╣ª╡╪┤≥┐¬╩²╛▌┐Γ " + file_alias +;
- ". ▒╛║»╩²╓┤╨╨╜½╩º░▄ "+;
- RETURN(.F.)
- ENDIF
-
- * ╢┴╚í▒φ═╖╡─╡┌╥╗╕÷╫╓╜┌
- keybyte = FREAD(handle,1)
- * ╜½╬─╝■╓╕╒δ╥╞╗╪╡┌╥╗╕÷╫╓╜┌
- = FSEEK(handle,0)
- * ╙├▒╚╘¡└┤╕▀┴╜╬╗╡─ ASC II ╫╓╖√╕─╨┤
- = FWRITE(handle,CHR(ASC(keybyte)+2))
- * ╣╪▒╒╬─╝■
- = FCLOSE(handle)
-
- RETURN(.T.)