Re: write results to virtual text file by mr_unreliable
mr_unreliable
Thu Mar 16 15:10:56 CST 2006
hi ljb,
Two answers, if you are courageous enough (or fool-hardy enough) to
use api's from script, then you can just use "the Heap".
Yes, "the Heap" sounds like some trashy grade "B" movie about some
scifi monsters crawling out of premoidal ooze, but "the Heap" is
really a way of managing system memory.
You allocate some memory for yourself, write your stuff into it,
read what you want out of it, and when you are done, release it.
But wait? You don't need api's for that, as vbs will do it for you.
If you just create a big array, then vbs itself will get space out
of "the Heap" for you and put you array into it. You can read/write
stuff from/to your array, and then when you are done (the array goes
"out-of-scope") then the memory gets released. This is part of the
wonderfulness of vbs that goes on behind the scenes.
Answer two. In many cases a "disk file" ain't so bad either. Have
you heard of "caching"??? Caching is some magic that the system
does for you. Let's say you read a small (disk) file. The file
goes into memory, and the system hands over the data to your app.
Then you read it again. Trick question: does the system go back
to the disk for the data? Answer: usually NOT. The system will
remember what the file is already sitting in memory, and just
read the memory for you again.
Truth: this is not a cure-all, because "caching" is a dynamic thing.
If the system needs the memory, your file becomes a candidate for
being kicked out of memory. Whether it actually does get kicked
out, depends on some algorithm which I'm not familiar with. But
regardless, the more memory you have, the longer your disk files
(or segments of them) will remain in memory, and give you the
benefits of caching.
Answer three (a bonus): you might take a look at the "dictionary
object" to hold your text snippets. It may be just what you want.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
ljb wrote:
> I often use the following to output vbscript results to a temporary text
> file so I can cut and paste text from it. Is there a way to make this a
> "virtual" text file that never gets written to disk? Perhaps something
> similar to ASP's Response.ContentType = "text".
>
> Set Shell = CreateObject("WScript.Shell")
> Set FSO = CreateObject("Scripting.FileSystemObject")
>
> InfoFile = FSO.GetTempName
> Path = Shell.Environment("Process")("Temp")
>
> FSO.CreateTextFile(Path & "\" & InfoFile, True).WriteLine Details
>
> CreateObject("Shell.Application").NameSpace(Path).ParseName(InfoFile).Invoke
> Verb
>
> WScript.Sleep 1000: FSO.DeleteFile Path, True
>
> Set Shell = Nothing
> Set FSO = Nothing
>
> thanks
> LJB
>
>