Re: about iterative loop to write numbers into file
- From: Alexander Mueller <millerax@xxxxxxxxxxx>
- Date: Wed, 14 Nov 2007 13:00:03 +0100
McKirahan schrieb:
"Alexander Mueller" wrotecrazyfisher schrieb:
iterativejust wondering is it possible to create a VBS script that uses antextloop to write the numbers from 1.0 to 1.9, then 2.0 to 2.9 etc up to afile?
How could I do that ?
Here's a shell script, numbers.cmd:
@ECHO OFF
SET F=%TMP%\numbers.txt
ECHO. > %F%
setlocal enabledelayedexpansion
FOR /L %%A in (1,1,99) do (
IF %%A LSS 10 (
SET S=0%%A
) ELSE (
SET S=%%A
)
ECHO !S:~,-1!.!S:~-1! >> %F%
)
endlocal
TYPE %F%
Alex, the OP asked for a VBScript ....
Sorry i didn't even dare to image how
an elaborated task such as writing numbers to a file
could be accomplished in VBScript.
Think you need 5+ years of Win-API lowlevel programming
before you can outline the roadmap of such
a lifetime project.
I would say first you design an interface
IWriter then you derive another interface
INumericWriter finally ISinglePrecisionNumericWriter.
Then you implement 2 abstract classes for the first to
interfaces that do the core IO-stuff and all advanced math,
then a concrete class that implements ISinglePrecisionNumericWriter
and extends CAbstractNumericWriter.
Next step could be an Iterator-interface
with some overloaded constructors.
You're still far from done. Hardest part is to write
the script engine that supports inheritance
and all the OO-stuff and which is syntactically
fully VBS-compatible also also the host that provides means
for object-creation using C'tors and other goodies WSH lacks.
Should be a 100% backward compatible to WSH; so all your customers
can migrate seamlessly with such an ease to your new
scripting-environment WSH+ FileWriter Edition.
For i = 1.0 To 3.0 Step 0.1 : s = s & FormatNumber(i,1) & vbCrLf : Next
CreateObject("Scripting.FileSystemObject").CreateTextFile("i.txt",True).Writ
e(s)
Great!
Mine is still sligthly more obfuscated,
though noone asked for.
MfG,
Alex
.
- Follow-Ups:
- Re: about iterative loop to write numbers into file
- From: crazyfisher
- Re: about iterative loop to write numbers into file
- References:
- Re: about iterative loop to write numbers into file
- From: Alexander Mueller
- Re: about iterative loop to write numbers into file
- From: McKirahan
- Re: about iterative loop to write numbers into file
- Prev by Date: Re: set users home folder permissions
- Next by Date: RE: exit loop after timeout (5 min)
- Previous by thread: Re: about iterative loop to write numbers into file
- Next by thread: Re: about iterative loop to write numbers into file
- Index(es):
Relevant Pages
|