Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Keyword Set

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Keyword Set
  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 >>
 Keyword Set - 8/13/2007 6:26:49 PM   
  Syslq

 

Posts: 3
Score: 0
Joined: 6/4/2007
Status: offline
Original message moved by ebgreen
Reason : Moved to proper forum
Set is supposed to set object reference to variable, I understand that
Set objFSO = CreateObject("Scripting.FileSystemObject")
Creates new instance of Scripting.FilesystemObject class (we create object)

But why do we use Set bellow, do we set reference to object method output also?
Set objTextFile = objFSO.OpenTextFile("c:\scripts\service_status.txt", ForAppending, True)

Thanks
 
 
Post #: 1
 
 RE: Keyword Set - 8/13/2007 6:56:21 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Wrong forum, but:

"Set" indicates the assignment, not the creation of an object. Cf:

   Set reX = New Regexp
   Set wmi = GetObject("winmgmts:")

The .OpenTextFile method returns an object that is assigned to
the receiving variable, hence "Set".

If you write a function returning an object, don't forget the "Set",
when you assign the object to be returned to the 'return value'
(same name as the function):

Function getRE( ... )
  ...
  Set getRE = ...
End Function

(in reply to Syslq)
 
 
Post #: 2
 
 RE: Keyword Set - 8/14/2007 1:06:56 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
ah, I learn something new every day, thanks...

Function getRE( ... )
...
Set getRE = ...
End Function

(in reply to ehvbs)
 
 
Post #: 3
 
 
 
  

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 >> Keyword Set 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