home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix CD 2.0
/
Phoenix_CD.cdr
/
01e
/
let12.zip
/
DEMO-5.BAT
< prev
next >
Wrap
DOS Batch File
|
1987-09-17
|
2KB
|
50 lines
echo Off
If `%Name%' == `' Demo
cls
echo ╔════════════════════════════════════════════════════════════════╗
echo ┌─╫────────────────────────────────────────────────────────────────╫─┐
echo │ ║ String Manipulation (part 2): LENGTH, SUBSTR, POS ║ │
echo └─╫────────────────────────────────────────────────────────────────╫─┘
echo ╚════════════════════════════════════════════════════════════════╝
echo
let P=(ask (concat "Give me a number between 1 and " (minus (length str) 9) ": " ))
if `%P%' == `' then LET P=(minus (length Str) 10)
let S=(substr Str P 10)
echo The ten characters of your string, starting from position %P% are
echo "%S%"
LET P=(pos (lower Str) "e")
LET P2=(pos (lower Str) "e" (+ P 1))
if not %p% == 0 goto OneP
echo Um, I had hoped to find a letter E somewhere in your string,
echo just to show you I could do it, but there just doesn't seem to
echo be any in it. May I entice you to go back and enter another
LET answer=(substr (upper (ask "string? ")) 1 1)
if `%Answer%' == `N' goto NoGo
if not `%Answer%' == 'Y' echo I'll just assume that to mean Yes, %Name%.
Echo I knew I could prevail upon your sensibilities. Thank you.
DEMO-4 AskAgain
:NoGo
Echo Very Well, %Name%, if you insist. I'll have to skip the next
Echo demonstration, though.
goto EndPos
:OneP
LET Ptr=(concat (dup " " (- P 1)) "^ Here in position " P)
echo I found a letter E in the string.
echo %Str%
echo %Ptr%
if not %P2% == 0 goto TwoPs
echo That also happens to be the only letter E in this string.
goto EndPos
:TwoPs
LET Ptr=(concat (dup " " (- P2 1)) "^")
echo There is another in position %P2%, here:
echo %Str%
echo %Ptr%
:EndPos
LET Answer=(ask (concat "Well, " Name ", are we having fun yet? ") 1)
echo (Never mind--rhetorical question)
set P2=
set ptr=
pause
DEMO-6