; PROGRAM: OPERATIONS ON A FILE
print macro s
mov dx, offset s
mov ah, 09h
int 21h
endm
data segment
nl db 0dh,0ah,'$'
menu db 'File Operations:',0dh,0ah,
'1.Hide 2.Unhide 3.Quit$'
choice db 'Choice: $'
msgFile db 0dh,0ah,'File: $'
msgNName db 'New Name: $'
invOp db 'Invalid Option!$'
path db 50 dup(0)
newn db 50 dup(0)
oldn db 50 dup(0)
msg_ok db 0dh,0ah,'File Operation Successfull!$'
msg_fail db 0dh,0ah,'File Operation Failed!$'
data ends
code segment
assume ds:data, cs:code
start:
mov ax, data
mov ds, ax
mov es, ax
print menu
ENTERCHOICE:
print nl
print choice
mov ah, 01h
int 21h
sub al, 30h
cmp al, 01h
je HIDEFILE
cmp al, 02h
je UNHIDEFILE
cmp al, 03h
je FINISH
print nl
print invOp
jmp ENTERCHOICE
HIDEFILE:
print msgFile
mov si, offset path
call readString
mov dx, offset path
mov ah, 43h
mov al, 01h ;to hide
mov cx, 02h
int 21h
jmp CHECKERROR
UNHIDEFILE:
print msgFile
mov si, offset path
call readString
mov dx, offset path
mov ah, 43h
mov al, 01h
mov cx, 00h
int 21h
CHECKERROR:
jc FAILED
print msg_ok
jmp ENTERCHOICE
FAILED:
print msg_fail
jmp ENTERCHOICE
FINISH:
mov ah, 4ch
int 21h
readString proc near
mov ah, 01h
READCHAR:
int 21h
cmp al, 0dh
je STRINGREAD
mov [si], al
inc si
jmp READCHAR
STRINGREAD:
;add a zero for file operations
mov [si], 00h
RET
readString endp
code ends
end start
**************************
OUTPUT
Z:\S5IT\masm>file_op
File Operations:
1.Hide 2.Unhide 3.Quit
Choice: 1
File: temp.txt
File Operation Successfull!
Choice: 2
File: temp.txt
File Operation Successfull!
Choice: 3
**************************
0 comments:
Post a Comment