Page 1 of 1

Simple OPEN problem

Posted: Tue Dec 16, 2008 9:59 am
by johnfin
I am having a problem with an OPEN statment bombing out. It is suppose to search a junk.tmp file for a string PN$=0992 then passes to FOUNDIT. The program just exits.

JUNKCHECKIT:
dro$ = "dir f:\" + PN$ + " > junk.tmp"
SHELL "cmd /c " + dro$
OPEN "junk.tmp" FOR INPUT AS #1
DO UNTIL EOF(1)
LINE INPUT #1, a$
IF INSTR(a$, PN$) <> 0 THEN
x$ = RTRIM$(LTRIM$(MID$(a$, 40, 4)))
IF x$ = PN$ THEN GOTO FOUNDIT
END
END IF
LOOP
CLOSE #1
RETURN

=================================
JUNK.TMP

Volume in drive F is DATA
Volume Serial Number is F0CA-6319

Directory of f:\0992

12/15/2008 02:40 PM <DIR> .
12/15/2008 02:40 PM <DIR> ..
12/15/2008 09:39 AM <DIR> 0992Junk
11/17/2008 01:22 PM 9,654,272 0992_Central.rvt
11/17/2008 01:22 PM <DIR> 0992_Central_backup
10/06/2008 10:17 AM <DIR> 0992_Correspondence

p.s.

Posted: Tue Dec 16, 2008 10:00 am
by johnfin
the spaces have been truncated in this posting of the directory listing. The true position for PN$ is 40 characters.

Posted: Tue Dec 16, 2008 2:46 pm
by burger2227
INSTR returns the start position of the text you are looking for, but you are not using that position in the MID$ statement.

According to your directory listing, there is no file named "0992" in that folder, so it is not in the "junk.tmp" file listing. Try using "0992*.*"

Ted