For example:
@echo off
set var1=hello
set var2=world
echo %var1% %var2%
The result is:
hello world
What if I wanted var1 to start on the 5th space and var2 to start on
the 15th.
Example:
hello world
...............
5th 15th character
Or how to set var1's last character to end on the 10th space and
var2's last character to end on the 20th.
Example:
hello world
....................
10th 20th character
Thanks!
Huy
See if this gives you an idea
@echo off
set var1=hello
(set var1= %var1%)
set var1=%var1:~-10%
set var2=world
(set var2= %var2%)
set var2=%var2:~-10%
echo %var1%%var2%
- - - - - - - - - - begin screen capture Win2000 - - - - - - - - - -
C:\cmd>ruler 30&demo\Spacing
....+....1....+....2....+....3
hello world
C:\cmd>rlist demo\Spacing.cmd
=====begin C:\cmd\demo\Spacing.cmd ====================
01. @echo off
02. setlocal
03. set var1=hello
04. set var2=world
05. for /l %%a in (1,1,2) do (
06. for /l %%b in (1,1,4) do (
07. set var%%a= !var%%a!
08. )
09. )
10. echo %var1% %var2%
=====end C:\cmd\demo\Spacing.cmd ====================
- - - - - - - - - - end screen capture Win2000 - - - - - - - - - -
--
Phil Robyn
Univ. of California, Berkeley
u n z i p m y a d d r e s s t o s e n d e - m a i l
I'm sorry foxidrive, NT4 doesn't know the minus variant. You will have to
get the length and do math.
OTOH there are 3rd party tools to do positioning:
wbat from Horst Schaeffer, http://home.mnet-online.de/horst.muc/
and
conset/conutils from Frank P. Westlake http://gearbox.maem.umr.edu/fwu/
--
Gruß
Matthias Tacke Email: Matt...@Tacke.de
---------+---------+---------+---------+---------+---------+---------+-------
The code seems great.. but it doesn't seem to work on Windows NT 4.0.
Perhaps I'm missing something. I know it's easily done with third
party tools. I've download some and and have working test batch
files. But I'm just curious if it can be done with pure batch or even
wsh enhanced batch files.
Thanks!
Huy
Phil Robyn <zipp...@berkeley.edu> wrote in message news:<2uv8t2F...@uni-berlin.de>...
> Perhaps I'm missing something. I know it's easily done with third
> party tools. I've download some and and have working test batch
> files. But I'm just curious if it can be done with pure batch or even
> wsh enhanced batch files.
You can also use an included program to position (colored) text on
the screen:
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>ctext.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>ctext.com
echo pZsAZ~ZzOL@KtZ{O@}1guN?_g~K=G?U_Pg]NYG?w?KgBw}IqtH@wR?wABO>>ctext.com
echo LrFZp{@XEKH@lQNgw@ECuQtj{OM?DG@@_Aqo{Ox{R?kNv@ZjosB@IoXEFr>>ctext.com
echo @W@K~Xj~@XeK??BB0x>>ctext.com
cls
echo 1. echo line
ctext 10 20 9 This is a light blue/black text at pos 10,20
ctext 11 20 2 This is a green/black text at pos 11,20
ctext 12 20 4 This is a red/black text at pos 12,20
ctext 13 20 12 This is a light red/black text at pos 13,20
echo 2. echo line
ctext +15 20 160 This is a black/light green text at pos 15,20
echo 3. echo line
del ctext.com
:: usage: ctext line column color text
:: write text with color "color" to screen at pos (line,column)
:: use a + before column to update cursor position
Phil's batch doesn't work due to the usage of delayed expansion (!),
which was introduced with win2000.
Change line 07 to :
call set "var%%a= %%var%%a%%"
HTH
--
Gruesse Greetings Saludos Saluti Salutations
Matthias
---------+---------+---------+---------+---------+---------+---------+
C:\>space.bat
!var1! !var2!
C:\>set var
var1= !var1!
var2= !var2!
The spacing seems off (probably just a matter of adjusting the
numbers). But the variables Hello World aren't being set. The
variables aren't being set properly on step 7 (at least on WinNT).
Thanks!
Huy
h...@exitentrance.com (Batch Newbie) wrote in message news:<81b6cb1b.04111...@posting.google.com>...
Matthias addendum to Phil's coding seems to be working great. I'll
need more time to figure out what all the codes mean and why it
actually does what it does :)
Hey Herbert.. I noticed several of your posts and like the idea of
creating a temporary application through echoing. Is there a site
with source of programs that can be echoed? Or how you obtaining the
code of a program in order to create it through echo? For example..
lets say I want to echo choice.exe ? I know it's not as simple as
popping in an executable into a text editor and then placing echo in
the front of each line and >name.exe on the first line and >>name.exe
in subsequent lines.
Thanks!
Huy
Herbert Kleebauer <kl...@unibwm.de> wrote in message news:<4199C4DB...@unibwm.de>...
It is only useful to include small executables (a few hundred bytes)
within a batch. I think choice.com (5 kbyte) is much to large.
If you want to include a com file and only have the binary, you can use
Laura's cm3 utility:
>Assemble .COM file using MASM6+ and convert .COM file
>to ascii-code using my CM3 utility ( http://lf.8k.com/TOOLS )
If you have the source code, you can also use:
ftp://137.193.64.130/pub/assembler/ube.zip
You can include any binary (not only com programs) if you use a
hex2bin converter and include a hex dump of the binary:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
if exist %0.bat %0.bat
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>h2b.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>h2b.com
echo ?@}I{uNWEF~NFAa_Lj@KLtH]~CEvEFIKbAa_wN@SuNS`{ECCttasae~BHM>>h2b.com
echo AcjFnvnHAwrvx[}gIKDw??Frt\gqj~{?s?csIsqo{O_KtBve{Sx{nB{Eu@>>h2b.com
echo fq`tkfk?e@oKCA_?_E@?WxAs?agBwRjnLK?s@w`G`LKLAcyA?@xAsZpk`L>>h2b.com
echo ~KxlqLct@vAc_A_yBJ@xAGZp?o?sBXq`LR@xUrFQt=A_E?B?~rB?~r0x>>h2b.com
:: usage: h2b "string" <infile >outfile
:: all lines in infile starting with "string" are converted
:: from hex to binary
h2b "::f1" <%0 >bild1.gif
h2b "::f2" <%0 >bild2.gif
del h2b.com
:: hex dump of bild1.gif
::f1 4749463839614b001100a20000140b00fffbf7ff6600fffcfa0000000000
::f1 000000000000002c000000004b0011000003a228badcfe30ca0901bd386b
::f1 66b7ff5f078e64242a419aa2eabaa84cebb2731d2cc39357f1cd0ab306ec
::f1 e503fa5cc8e26cc06c30778d53f0e758d988c6c715f7643ca10ae9902abc
::f1 6db35372faebed86cb4399d23c6f917b32079bdb7c576169687354816702
::f1 7b0a887e5a747f79593f8583897d7c0f6258695b9b479d58893a26704976
::f1 909041a493a61e2725ae25adafb2acb3b52100b8b9babbbcbdbebfc0c1bf
::f1 09003b
:: hex dump of bild2.gif
::f2 47494638396121001000b30000fffdfbff6702ffc39aff9e5effdfcaffef
::f2 e5fff8f4ffffffc0c0c00000000000000000000000000000000000000000
::f2 0021f90401000008002c0000000021001000000463f0c849abbd385f3384
::f2 fe9911041e2811432a1499300e00388c743010d83ce26deddf16110d78d1
::f2 f96a1dd6c485e4518ed0a1406044962451a80aa5751eaadd0a73a8a48c8f
::f2 83f2a480548bd1ee892e0d2a4c05841886793581847d7e1f007882862611
::f2 003b
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If the binary is smaller than about 40 kbyte, you can also include
a com file which, when executed, generates the binary file:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>gver.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>gver.com
echo T}{zs~@gwkCG@OEKcUt`s}@mqqCsy?seHCsaPhxr?@zAB`LrPEyoDt@Cj?>>gver.com
echo pky_jN@QEKpEt@ij?jySjN@REKpEt@jj?jyGjN@SEKkjtlGuNw?p@pjirz>>gver.com
echo VRvAZYX??YLtX@@?~XCo?V~rDZ@?bZ?@MV@?os1GG`Lb~eafgXzoG?Ca~g>>gver.com
echo O1wG?w?ygF?fyALHsq@w`G`LKLsdrTdu_Sl1qTni`To=q@ooo?ooo?ILo?>>gver.com
echo sdrTdu_Sl1qTnmhTo=q@ooo?ooo?ILo?sdrTdu_Sa1qTkhtTo=c@ooo?oo>>gver.com
echo o?ILo?sdrTdu_So1qTs`kTe=ePeeeTeeeTILe@sdrTdu_Sb1qT=crDxc__>>gver.com
echo @?AooG_B?@?~NcC?fOCGf?SCG_K_aFDsFBkzZBUKDOKS@KVCO?@OudxH_F>>gver.com
echo Zo@N??D@J?C?K?UHZoOXO?Y_X?OV?@VAX?EZC?FZC?CX_?BDZ?OCZ?YOV?>>gver.com
echo OVO?ODZ?[IZ?{VO?ORZCZ[V?smYOswdTAoXGXOX?CXC?_LZ?Z_VK1Z~rZO>>gver.com
echo k@O[DGOiVGOyVGOEVKcDZOHZO?XOW@GVO_HZO?VOy@ZOG?RTTSrQDDcmqO>>gver.com
echo VkkDZOk@dLFS`rrTAdfT@wnTDJ?SDMQTqrK@kcmS[Vk`iVO_yVO_EVOoFZ>>gver.com
echo O?hwDTqOsTdbnTXrrDsdFTcsRTm`GTdkcTqVYSdshTkhETFXdPUsdTrqdT>>gver.com
echo mnhT@wDT[g?C??QCST~B??OCPU}A~??`?Q_OC=?GcgXkFJXGCFBMX_gFmt>>gver.com
echo LtXQgJg}H}iXJQT~?K?OGOdr?Su_sP1qdTi`lT=qnDdr?Su_sP1qdTmhlT>>gver.com
echo =qnDdr?Su_sP1qdThtaT=ckDdr?Su_sP1qdT`koT=esDdr?Su_sP1qdTcr>>gver.com
echo bTU?=OXGxAPM}I@??pGC?ba?Azy?NwBuHCfA?MoA?MEUGQ}gan?PMQLg?K>>gver.com
echo B]XsLFZ?I?I_GEECFs?FXBgBBqj~QEaAp??@DB?B?QSOLt?C~ti=OKT?b?>>gver.com
echo ?`?QSO?i?CQWg@i??PEg@C??QCT~OL?OOO?H?oi[tPFg?C??QCQFg@i??P>>gver.com
echo T~?K?O?O?i?CGT~B??OCW=@A??QCtX@O?BWNhqvT_dsDqqdTZqnDZSHGaZ>>gver.com
echo ~r0x>>gver.com
gver.com>gver.exe
gver.exe>gver.bat
call gver.bat
for %%i in (com exe bat) do del gver.%%i
echo PlatformId=%ver_platf%
echo MajorVersion=%ver_major%
echo MinorVersion=%ver_minor%
echo BuildNumber=%ver_build%
echo CSDVersion=%ver_csd%
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If you need choice only to read a character, you can use instead:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>getkey.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>getkey.com
echo L?p{KsUWK`LR0x>>getkey.com
getkey.com
if errorlevel 89 if not errorlevel 90 echo Y key pressed
if errorlevel 121 if not errorlevel 122 echo y key pressed
if errorlevel 78 if not errorlevel 79 echo N key pressed
if errorlevel 110 if not errorlevel 111 echo n key pressed
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
The source code:
; read character from keyboard and return ascii
; value as errorlevel
@=$100
00000100: 31 c0 eor.w r0,r0
00000102: cd 16 trap #$16
00000104: b4 4c move.b #$4c,m0
00000106: cd 21 trap #$21
Delayed expansion or the use of a call is neccesary to to evaluate
the vars in a specific order.
set var%%a= !var%%a!
The percent vars evaluated first giving,
set var1= !var1!
set var2= !var2!
then the ! vars follow, this way adding a space on each turn of the
inner for.
The call with help of doubled percent signs work similar. To escape
a percent sign you have to double it. The call causes the line to be
evaluated twice, at first run inserting values for %%a and changing
the doubled percent to a single one. So
call set var%%a= %%var%%a%%
gets:
set var1= %var1%
This use of call is AFAIK undocumented and works in combination with
the for set commands.
Upon further testing (figured out what the for statements does).. the
Phil's code with Matthias' contribution only pads spaces in front of
the variables and doesn't actually make the variables start at a
predetermined position (or end at a predetermined position.
01. @echo off
02. setlocal
03. set var1=hello
04. set var2=world
05. for /l %%a in (1,1,2) do (
06. for /l %%b in (1,1,5) do (
07. call set "var%%a= %%var%%a%%"
08. )
09. )
10. echo 123456789012345678901234567890
11. echo %var1%%var2%
Result is:
C:>space.bat
123456789012345678901234567890
hello world
Hello ends at position 10 and world ends at position 20. However,
this is only true if var1 and var2 is only 5 characters long (since it
is just padding). If it they are shorter or longer than 5 characters
then it is broken.
I've experimented with Herbert's ctext.com program. Looks great but
it appears to just assign starting positions of variables and not
ending positions.
I feel tears coming down :)
with a HEX dump both gif files take up 908 bytes in the batch files
using yenc they would take up 557 bytes
it cuts the size by 40%
Herbert Kleebauer <kl...@unibwm.de> wrote in
You missed the point. If there is a binary channel so you can
transfer the decoder program (uuencode, mime or yenc) then
you also can transfer the binary gif the same way, no need to
encode it at all. But if you don't have such a binary channel,
then you have to transfer the decoder program also with the ascii
channel. And then it makes more sense to use a simple encoding
to get a small decoder because you have to minimize the sum
of the decoder size + the encoded gif size.