• Creator
  • #4179


    This is a very basic question, but I can’t find the answer. Maybe someone here can help me.

    How do I create a new file on the (local) filesystem and write plain text to it?

    I have written a tool to import about 50 address book, and I sent the logging to an administrator. But the logging is too big for a messagebody, so I want to create a log file and sent it as an attachment.

    A simple solution as I used to use in earlier versions of (Visual) Basic is

    open “file” for output as #1
    print #1 “My log entry”
    close #1

    but this results in compile errors in Formativ.

    Who can help me?

    Kind regards,
    Roland Leurs

  • Author
  • #7370

    Check the Formativ Language Guide and Visual Basic Script Guide for more information. Here is some of the options available:

    – Use SaveStringToFile method to save a string value to a file.
    call utilities.SaveStringToFile(“My log entry”, “c:tempmylog.txt”, true)

    – Creates a new StringList object and call SaveToFile method to save the strings in the list to a file.
    dim oList
    set oList = utilities.StringList
    oList.add(“Line 1”)
    oList.add(“Line 2”)
    set oList = nothing

    Hope this helps.

    Support 1a

    Thanks MA.

    Advansys Support


    Another way Razz

    Direct with VBS

    Set fso = CreateObject(“Scripting.FileSystemObject”)
    Fic_Path = “C:somewhere in file system”

    Set tempfile = fso.CreateTextFile(Path)

    tempfile.WriteLine (“Arcane GroupWare”)
    tempfile.WriteLine( “[Fic_Vis_Cat]”)
    tempfile.WriteLine( “Téléphone” )

    L.P. Irovetz

    Support 1a

    Thanks LP!

    Advansys Support


    I implemented the version of L.P. Irovetz as it writes directly to the logfile. So if the applet crashes I even have some logging. This is a major difference compared to the solution of MA.

    Just had to change fso.CreateTextFile(Path) to fso.CreateTextFile(Fic_Path).

    Thanks for your response!
    Roland Leurs

    Support 1


    It may be worthwhile testing to ensure that, in the event of a crash, your log entries have been saved to the log file. This is because the text may not be flushed from memory to disk until the line


    executes, or the memory buffer is full.

    A simple way to test is to write an applet which fails to call tempfile.Close.

    It may be worth also looking at function Utilities.Trace which is documented in the Formativ Language Guide. This is particularly useful for debugging an applet with the help of an external debug event viewer.

    Advansys Support

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.