Discussion:
Ucase$ ?
(too old to reply)
Big-Dave
2003-08-11 04:31:54 UTC
Permalink
OPEN "winn.txt" FOR INPUT AS #1
OPEN "Pepsi.txt" FOR OUTPUT AS #2
LET p$ = "Pepsi"
DO
LINE INPUT #1, a$
IF MID$(a$, 17, 5) = p$ THEN PRINT #2, a$
LOOP UNTIL (EOF(1))

'I use PB35

'How would I get a$ to print if p$ is
'Pepsi or pePsi or PEPSi...
'In other words the program works fine
' if p$ is the right case, I would like
' it to work if p$ is mixed case.
Thanks
Dave



--
\||/
_____oOO_\(..)/_OO____
__|_____|____/ \___|__gnv|__
|_____|_____|_\__/|_____|_____|
__|____David L. Bishop____|__
|___Http://www.sstar.com/washer
|_____|_____|_____|_____|
n***@bounceall.net
2003-08-11 09:54:00 UTC
Permalink
Post by Big-Dave
OPEN "winn.txt" FOR INPUT AS #1
OPEN "Pepsi.txt" FOR OUTPUT AS #2
LET p$ = "Pepsi"
DO
LINE INPUT #1, a$
IF MID$(a$, 17, 5) = p$ THEN PRINT #2, a$
LOOP UNTIL (EOF(1))
'I use PB35
'How would I get a$ to print if p$ is
'Pepsi or pePsi or PEPSi...
'In other words the program works fine
' if p$ is the right case, I would like
' it to work if p$ is mixed case.
Thanks
Dave
--
\||/
_____oOO_\(..)/_OO____
__|_____|____/ \___|__gnv|__
|_____|_____|_\__/|_____|_____|
__|____David L. Bishop____|__
|___Http://www.sstar.com/washer
|_____|_____|_____|_____|
Change this line IF MID$(a$, 17, 5) = p$ THEN PRINT #2, a$
to IF UCASE$(MID$(a$, 17, 5)) = UCASE$(p$) THEN PRINT #2, a$

Better yet put the LET p$ = "Pepsi" outside the loop, at the top (for
efficiency) and have it be LET p$ = "PEPSI" then the IF can be
IF UCASE$(MID$(a$, 17, 5)) = p$ THEN PRINT #2, a$


LB
Big-Dave
2003-08-11 19:13:12 UTC
Permalink
'Hi, the fix worked GREAT.
' Thanks
' Dave

Example:
LET p$ = "PEPSI"
CLS
REM =-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=
'
OPEN "winn.txt" FOR INPUT AS #1
'
OPEN "Pepsi.txt" FOR OUTPUT AS #2
DO
LINE INPUT #1, a$
IF UCASE$(MID$(a$, 17, 5)) = p$ THEN PRINT #2, a$
'
'old code... IF MID$(a$, 17, 5) = p$ THEN PRINT #2, a$
'
LOOP UNTIL (EOF(1))
CLOSE #1
CLOSE #2
SYSTEM
John van Poelgeest
2003-08-12 20:31:57 UTC
Permalink
However, now you have to adapt the source, so that all input will be
uppercase (let P$="PEPSI"), and Pepsi, pEpsi and PePsI are still not
recognized.

Simple solution:

Change the (in)famous line to:

IF UCASE$(MID$(a$, 17, 5)) = UCASE$(p$) THEN PRINT #2, a$

and it does not matter anymore in what case any of the strings are.
Michael Kennedy
2003-08-12 19:32:40 UTC
Permalink
Just another 2 cents...

If your "winn.txt" file is EMPTY, the "Line Input" line may fall over.
Post by n***@bounceall.net
LET p$ = "PEPSI"
CLS
OPEN "winn.txt" FOR INPUT AS #1
OPEN "Pepsi.txt" FOR OUTPUT AS #2
WHILE not EOF(1)
LINE INPUT #1, a$
IF UCASE$(MID$(a$, 17, 5)) = p$ THEN PRINT #2, a$
WEND
CLOSE #1
CLOSE #2
SYSTEM
Mike

Loading...