home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix CD 2.0
/
Phoenix_CD.cdr
/
01e
/
let12.zip
/
DEMO-10.BAT
< prev
next >
Wrap
DOS Batch File
|
1987-09-17
|
2KB
|
62 lines
echo Off
If `%Name%' == `' Demo
cls
echo ╔════════════════════════════════════════════════════════════════╗
echo ┌─╫────────────────────────────────────────────────────────────────╫─┐
echo │ ║ Data Formatting: FILL ║ │
echo └─╫────────────────────────────────────────────────────────────────╫─┘
echo ╚════════════════════════════════════════════════════════════════╝
echo
echo Here's a handy little feature: data formatting.
echo
echo This is how we do it. Imagine a template, or pattern as we'll
echo call it, which consist of two kinds of characters: fill-characters
echo and "stuff." For example, we have a pattern below:
set Rfill=≤≤≤,≤≤≤,≤≤≤,≤≤≤.≤≤
echo
echo %Rfill%
echo
echo The little less-than-or-equal signs (≤) are fill-characters, and the
echo commas and period are "stuff." Imagine now, that we can fill data
echo into this pattern, in effect replacing the fill-characters with data,
echo but leaving the "stuff." Here: I'll show you. What is your self-
echo estimated value to your employer (this is usually your salary with the
echo decimal point moved a few places to the right) Try to keep it a number
echo less than a million--understatement is the better part of tact.
LET num=(replace (ask "Well? What are you worth? ") "$" "" "," "" " " "")
LET P=(pos num ".")
if %P% == 0 LET num=(concat num "00")
if not %P% == 0 LET num=(replace num "." "")
echo I've doctored that number up so that I can use it: %num%
echo Now, let us fill that number into your pattern and see what we get.
LET result=(fill Rfill (concat " " num))
echo
echo This gives us the result of "%result%"
echo But wait! We can suppress the "stuff" that shouldn't be there!
echo (I deliberately prevented the suppression to show you how data
echo gets filled.) Any leading commas can be zapped away--
LET dummy=(ask "automatically--press RETURN to go on. ")
LET result=(fill Rfill num " ")
echo
echo With suppression, we get
echo
echo "%result%"
echo
echo You want a floating dollarsign? Ok.
LET result=(fill Rfill num " $")
echo
echo "%result%"
echo
echo How about asterisk filling
LET result=(fill Rfill num "*$")
echo
echo "%result%"
echo
Echo How's that?
set Result=
set Rfill=
set P=
set num=
pause
DEMO-11