Re: about iterative loop to write numbers into file



thanks all for your reply....


"Alexander Mueller" wrote:

McKirahan schrieb:

"Alexander Mueller" wrote
crazyfisher schrieb:

just wondering is it possible to create a VBS script that uses an
iterative
loop to write the numbers from 1.0 to 1.9, then 2.0 to 2.9 etc up to a
text
file?
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





.



Relevant Pages

  • Re: about iterative loop to write numbers into file
    ... @ECHO OFF ... I would say first you design an interface ... the script engine that supports inheritance ... Should be a 100% backward compatible to WSH; ...
    (microsoft.public.scripting.vbscript)
  • Wireless CETK tests wzctooltest.dll
    ... SDIO card. ... ECHO:WARNING this test needs XWIFI11B1 [has PEGASSDN1] ... ECHO: Default Gateway ... ... ECHO: Interface Number .. ...
    (microsoft.public.windowsce.platbuilder)
  • Cant connect to firewall
    ... # IPCHAINS FIREWALL script for the Linux 2.2 kernel. ... # The default value below is for a 192.168.0.0 network. ... The internal interface will likely have ... echo " Enabling IP forwarding..." ...
    (Debian-User)
  • Re: Set Full Duplex on AIX
    ... Actually I have written the following script that interactively ... displays all options available per interface and changes them without ... echo "\nWARNING: THIS OPERATION WILL CUTT OFF ANY APPLETALK/NFS/TCPIP ... $CHENT ...
    (comp.unix.aix)
  • Re: issues with pipe operator causing hang while executing a batch fil
    ... You can hardly in and out the result of a pipe ever efficiently.+ ... use wsh to write the thing to file system and read it back in. ... echo "Iteration %1 " ... It should not have run more than a single iteration due to the lack of CALL ...
    (microsoft.public.scripting.wsh)