Lee wrote:Ill post the whole program right now
OPEN "Actordat.txt" FOR INPUT AS #1
- If the file is not there, this instruction will fail to run
- It will fail anyway because filenames are limited to 8.3
- Try "Actor.txt"
if kp$ = "s" then goto srcaktr
if kp$ = "e" then goto ext
loop
- Why are these in lower case? Have you even tried the program?
- Please copy code from running programs
if sactname$ = actname$ then
- Since actname$ has no value, this IF statement will never work
SHELL "cd C:\ZSOACTRDAT"
- This will fail due to long file name.
- Rename the directory and try "cd C:\ZSOACTRS"
Your FIND command is hopeless. Try this
cmd$ = "FIND /I " + CHR$(34) + sactname$ + CHR$(34) + " Actordat.txt"
PRINT cmd$
SHELL cmd$
By printing the cmd$, you can see what you are asking DOS to do.
Finally, what is the SLEEP 10 for? What does any of this have to do with the INPUT #1 command that follows? Do you think that because the FIND program found sactname$ that your program is set to read that record? DOS doesn't return file position to your program, even if you give it 10 seconds.
My guess is that you are a beginner programmer who is trying much too tough an initial project. Stick to simpler programs for a few months until your skills improve. It is very difficult to write a database program. Below is some working code that abandons the SHELL concept, as suggested by Nodtveidt. It will work assuming you have the file and it contains stuff like
"John Smith", "Group1","34343","12"
"Mary Jones", "Group2","22","22"
"John Brown", "Group3","3437","43"
As you can see, it needs still more work: What happens if I enter "John" and wanted "John Brown"? And if I enter "M" I will get "John Smith", not
"Mary Jones" because of the "m" in smith. And what would I do with the data? Just look at it? The list goes on. Database programs are tough.
Mac
Code: Select all
CONST ActorFile = "C:\ZSOACTRS\Actordat.txt"
DIM SHARED MyErr AS INTEGER
MyErr = 0: ON ERROR GOTO GetMyErr
OPEN ActorFile FOR INPUT AS #1
ON ERROR GOTO 0
IF MyErr > 0 THEN PRINT "Unable to find "; ActorFile: SYSTEM
' Test format
DO WHILE NOT EOF(1)
FOR i = 1 TO 4
IF EOF(1) THEN
PRINT "Format error in "; ActorFile
SYSTEM
ELSE
INPUT #1, l$
END IF
NEXT i
LOOP
CLOSE #1
' OK, there is a good file
CLS
DO
PRINT : LINE INPUT "Actor name, or part of one: ", sactname$
IF sactname$ = "" THEN EXIT DO
GotIt = 0
OPEN ActorFile FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, actname$
IF INSTR(UCASE$(actname$), UCASE$(sactname$)) > 0 THEN GotIt = -1: EXIT DO
FOR i = 1 TO 3: INPUT #1, l$: NEXT i
LOOP
IF GotIt THEN
INPUT #1, groupnum$, actornum$, pactnum$
PRINT "Found "; actname$; " "; groupnum$; " "; actornum$; " "; pactnum$
ELSE
PRINT "Unable to find "; sactname$
END IF
CLOSE #1
LOOP
PRINT "End of Run"
SYSTEM
GetMyErr: MyErr = ERR: RESUME NEXT