none
create a file RRS feed

  • Question

  • I have an array the I would like to put out to a computer file. Also, would then like to read it in. Tried in my own way, but it said -failed -  access denied. Can someone give me a small program that will do this.
    Monday, March 27, 2017 11:58 PM

Answers

  • BEAR6994,

    Here it is! The access denied that you are getting may be due to where you are trying to write the file. If you make a temp folder in c:\ as I showed in the example it should work OK. Another place that you could write the file would be: c:\users\XXX\documents\test.txt. You need to look in c:\users to get what XXX is.

    Arr[1]="This"
    Arr[2]="That"
    Arr[3]="And"
    Arr[4]="Another"
    File.WriteContents("C:\temp\test.txt",Arr)
    MyArray=File.ReadContents("C:\temp\test.txt")
    For x=1 To 4
      TextWindow.WriteLine("Here it is: "+MyArray[x])
    EndFor


    JR

    Tuesday, March 28, 2017 9:45 AM
    Answerer
  • Or you can use the Programdirectory:

    '' write and read file 170328
    outFile= Program.Directory+"\testfile.txt"
    For i=1 To 10
      Array[i]=i*i*i
    EndFor
    File.WriteContents(outFile,Array)
    
    Brray= File.ReadContents(outFile)
    For i=1 To 10
      TextWindow.WriteLine(i+":"+Brray[i])
    EndFor
    


    Jan [ WhTurner ] The Netherlands

    Tuesday, March 28, 2017 9:57 AM
    Answerer

All replies

  • BEAR6994,

    Here it is! The access denied that you are getting may be due to where you are trying to write the file. If you make a temp folder in c:\ as I showed in the example it should work OK. Another place that you could write the file would be: c:\users\XXX\documents\test.txt. You need to look in c:\users to get what XXX is.

    Arr[1]="This"
    Arr[2]="That"
    Arr[3]="And"
    Arr[4]="Another"
    File.WriteContents("C:\temp\test.txt",Arr)
    MyArray=File.ReadContents("C:\temp\test.txt")
    For x=1 To 4
      TextWindow.WriteLine("Here it is: "+MyArray[x])
    EndFor


    JR

    Tuesday, March 28, 2017 9:45 AM
    Answerer
  • Or you can use the Programdirectory:

    '' write and read file 170328
    outFile= Program.Directory+"\testfile.txt"
    For i=1 To 10
      Array[i]=i*i*i
    EndFor
    File.WriteContents(outFile,Array)
    
    Brray= File.ReadContents(outFile)
    For i=1 To 10
      TextWindow.WriteLine(i+":"+Brray[i])
    EndFor
    


    Jan [ WhTurner ] The Netherlands

    Tuesday, March 28, 2017 9:57 AM
    Answerer