1 Reply Latest reply: Jan 4, 2012 8:06 AM by Miguel Angel Baeyens de Arce RSS

    Writing log using a VB macro



      I'm trying to use a VB macro inside the QV loading script in order to write an activity log, but I'm not having luck.


      First, this is the code included in the macro section:



      Dim objFSO
      Dim logFile
      Function openOutputFile(filename)
      Rem *** Create and open an output file
          CONST ForWriting = 2
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          Set openOutputFile = objFSO.OpenTextFile(filename, ForWriting, True)
      End Function
      CONST LOGFILE_NAME = "D:\tmp\test1.log"
      Function WriteLog(message)
          logFile = openOutputFile(LOGFILE_NAME)
      End Function


      and inside the QV script, (i.e. in Main tab) the WriteLog function is invoked:


      LET x = WriteLog("test");


      The file is being created, but it is empty.


      Could you please provide some advice


      Thanks in advance!