Archive

Posts Tagged ‘code within code’

Packing code within code – a HTA exercise in string manipulation

February 16, 2010 Leave a comment

I was working on a HTA tool this week, and to make things easier I wanted to encapsulate another HTA within it – really I just didn’t want to have to send two files to the user, I wanted everything in one, and rather than take the obvious approach of putting them both into a self-extracting zip, I decided to work out how to include the code of File B in File A.

Note – you can find the test files for this article on my companion site, CTOGoneWild

Pretty easy stuff I thought, just split B up into a string, and include a simple routine to write it out to the temp directory

    1 : Dim s : s="Some text to output to a file" &_
    2 :   " which is more than one line and go" &_
    4 :   "es on a bit."
    6 : Dim fso: Set fso = CreateObject("Scripting.filesystemobject")
    8 : fso.createtextfile("test.txt").write s

Read more…

Advertisements
Categories: Programming Tags: , ,