Announcement

Collapse
No announcement yet.

Template Wizard Text File Update?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Template Wizard Text File Update?

    Is there a way to have the VTW read in a text file, delete the text in it and then send out new text to that file (based on what is input in the template) that will then update to a scene?

    Basically, I have a scene that reads in a numeric value from a text file. The only way to change that value in the scene is to update the .txt file and save it. I would like to make the process more user friendly for the producers. Not even sure if this is possible but thought I would ask.

    So far this is all I have for a script (and it's really nothing) is...

    Sub REDADDTENCLICK(Sender)
    Dim RedPath As String = "V:/RED_TEAM.txt"

    end sub


    Any info would be awesome, Thanks

  • #2
    Try with this code

    Code:
    ' Read all content of a txt file
    Sub readClick(Sender)
                    'declarations
    dim TempFile
    dim MyFSO
    dim TempString
                    'create File system obj
            set MyFSO = CreateObject("Scripting.FileSystemObject")
                    'open the file
            set TempFile = MyFSO.OpenTextFile("D:\test.txt", 1)
                            'read the data
                    TempString = TempFile.ReadAll()
                            'if needed you can split further and populate an array. atm just filling an Unicode memo
                    text_box.UTF8Text = TempString
                            'closing file flushing FSO
                    TempFile.Close
            set MyFSO = Nothing
    End sub
    
    ' Read content of a txt file Line by Line
    Sub read_linesClick(Sender)
    'declarations
    dim TempFile
    dim MyFSO
    dim TempString
    
                    'create File system obj
            set MyFSO = CreateObject("Scripting.FileSystemObject")
                    'open the file
            set TempFile = MyFSO.OpenTextFile("D:\test.txt", 1)
                    'clear the contents of a listbox which is to be filled with lines
            TWUniListBox1.Items.Clear
                    Do While Not TempFile.AtEndOfStream
                            TempString = TempFile.ReadLine()
                            TWUniListBox1.Items.Add(TempString)
                            'Do something else or whatever you need to with the line
                    Loop
                            'closing file flushing FSO
                    TempFile.Close
            set MyFSO = Nothing
    End sub
    
    'Save a component from your template to a txt file
    Sub saveClick(Sender)
    'declarations
    dim TempFile
    dim MyFSO
    
    
                    'create File system obj
            set MyFSO = CreateObject("Scripting.FileSystemObject")
                    'open the file with  <filename>, IOMode (1=Read,2=write,8=Append),
                    'Create (true,false), Format (-2=System Default,-1=Unicode,0=ASCII)
            set TempFile = MyFSO.OpenTextFile("D:\test.txt",2,true)
                            'write the data
                    TempFile.WriteLine(text_box.UTF8Text)
                            'Closing file, flushing FSO
                    TempFile.Close
            set MyFSO = Nothing
    
    
    End sub
    Have fun

    Comment


    • #3
      That's what I was looking for, thank you!

      Comment


      • #4
        nice example
        thanks

        Comment


        • #5
          mabulazm
          Active Forum user
          mabulazm was this what you were looking for?

          Comment

          Working...
          X