Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Reading from a file, and writing to a container

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,44992
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Reading from a file, and writing to a container
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Reading from a file, and writing to a container - 3/26/2007 5:27:49 AM   
  zokissima

 

Posts: 13
Score: 0
Joined: 3/26/2007
Status: offline
Hi all

Total n00b here, so if I may be forgiven any transgressions, I'd really appreciate any help I can get. I've just been muddling through, did a few searches, and found some useful stuff, but I just don't have the knowledge to put it all together.

Basically, I need to construct a script that will read the contents of one text file, and write the results into a container within a second text file. This is for the construction of an SMS mif file, which requires a certain format for it to be recognized in a scan.

Each of our register machies has an application identifier that is unique to that register, and is what is used in communications. When I give people host names, they just stare at me. So, basically, I have written a CMD program (if it can be called as such :p ) that extracts this id, and pumps it into a text file.
It is just a single line of information, ie ID=099

I need to read the contents of this text file into a variable, then output this variable into a totally new text file, but within a specific format.
For example, all mif files have a general layout of the following:

ATTRIBUTE
NAME = "blahblah"
ID = 1
TYPE = String(250)
VALUE = "ID=099"   (notice, it is this that I need to create)
END ATTRIBUTE

I have muddled around a bit, and found a basic method to read this input (gathered from this very forum) :

Dim InputFile
Dim FSO, oFile
Dim strData
InputFile = "C:\IDtest.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.OpenTextFile(InputFile)
strData = oFile.ReadAll
oFile.Close

I also know how to print out lines, one by one.

I am just at a loss as to how to print out several pre-determined text strings, then populate the variable, print it, and then proceed with the rest of the pre-determined strings.

I hope that this is clear enough. I apologise for the lengthy post, but I'm just in a very tight deadline right now. I would greatly appreciate any assistance you guys/gals can offer :)
 
 
Post #: 1
 
 RE: Reading from a file, and writing to a container - 3/26/2007 5:46:22 AM   
  dm_4ever


Posts: 2359
Score: 36
Joined: 6/29/2006
From: Orange County, California
Status: offline
Not sure if I understood completely, but maybe this will get you started:


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zokissima)
 
 
Post #: 2
 
 RE: Reading from a file, and writing to a container - 3/26/2007 5:50:22 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Just to muddy the waters further, the SMS client exposes a COM object that will allow for the creation of .mif files.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Reading from a file, and writing to a container - 3/26/2007 5:52:54 AM   
  dm_4ever


Posts: 2359
Score: 36
Joined: 6/29/2006
From: Orange County, California
Status: offline
Well, that would be your best bet zokissima, the COM object ebgreen mentioned. I can't help with that though...never played with it.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ebgreen)
 
 
Post #: 4
 
 RE: Reading from a file, and writing to a container - 3/26/2007 5:59:45 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Now I'm going to need to dig up sample code aren't I? 

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: Reading from a file, and writing to a container - 3/26/2007 6:15:49 AM   
  zokissima

 

Posts: 13
Score: 0
Joined: 3/26/2007
Status: offline
dm_4ever: Oh yes!!! That's it. My man, you've just made my day. I can extend that code to read any number of files and add any number of lines. This is fantastic. I very much appreciate it :)

I dunno if you guys have some sort of user rating system by any chance?

< Message edited by zokissima -- 3/26/2007 6:17:26 AM >

(in reply to dm_4ever)
 
 
Post #: 6
 
 RE: Reading from a file, and writing to a container - 3/26/2007 6:16:48 AM   
  zokissima

 

Posts: 13
Score: 0
Joined: 3/26/2007
Status: offline
quote:

ORIGINAL: ebgreen

Just to muddy the waters further, the SMS client exposes a COM object that will allow for the creation of .mif files.

Explain...?

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: Reading from a file, and writing to a container - 3/26/2007 6:33:37 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
I have only used a portion of the object's functionality to create installation status mifs in the past. Here is some quick code:

Dim MIF:Set MIF=CreateObject("ISMIFCOM.InstallStatusMIF")
Dim message
'creating status MIF
If status = LCase("fail") Then
message="Failure Occured - Key value = " & strResult
status = 0
Else
message="Completed Successfully - Key value = " & strResult
status = 1
End If

MIF.Create "Status","Some Company Name","Some Installation Name","1.0","1033"," ",""& message&"", status

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zokissima)
 
 
Post #: 8
 
 RE: Reading from a file, and writing to a container - 3/26/2007 6:39:50 AM   
  zokissima

 

Posts: 13
Score: 0
Joined: 3/26/2007
Status: offline
/\/\ Thanks for that, I appreciate your time. Whenever I find time, I think I may want to look more into this. Any clue where a good place to go for documentation is?
I can already think of a few instances where I could use this. Thanks again :)

< Message edited by zokissima -- 3/26/2007 6:41:08 AM >

(in reply to ebgreen)
 
 
Post #: 9
 
 RE: Reading from a file, and writing to a container - 3/26/2007 6:43:04 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
try here:

http://spa.its.uiowa.edu/ecm/imaging/SMS/Scripting%20SMS%20Operations.pdf

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zokissima)
 
 
Post #: 10
 
 RE: Reading from a file, and writing to a container - 3/26/2007 6:47:45 AM   
  zokissima

 

Posts: 13
Score: 0
Joined: 3/26/2007
Status: offline
Great. Thanks for all the help you two, it has proven that my day was not spent in futility after all
I'll finish off the package tomorrow and test, so hopefully all goes well.

(in reply to ebgreen)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Reading from a file, and writing to a container Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts