Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: civilseal on November 04, 2015, 09:12:33 AM

Title: How do I write to or change a specific part of a file?
Post by: civilseal on November 04, 2015, 09:12:33 AM
How can I control where to write in a file?
For example if I do this:
Dim X As Double
  Open "C:\Mach3\myfile\myFile.txt" For Output As #1
  X = GetDRO(0)
  Y = GetDRO(1)
  Z = GetDRO(2)
  Print #1, X
  Print #1, Y
  Print #1, Z
  Close #1


But then maybe I just want to write the value of the Y axis and have the other ones intact, or if I want to add more and more values after the others, how can I control where in the file the value is written?
Title: Re: How do I write to or change a specific part of a file?
Post by: BR549 on November 04, 2015, 10:28:47 AM
You can write to individual lines by number of teh line AND you can write to a specific Part of that line by position in that line.

Study,study,study

(;-) TP
Title: Re: How do I write to or change a specific part of a file?
Post by: civilseal on November 04, 2015, 11:14:40 AM
Yes thats what I´m trying to find info about but has not yet succeded and thats why I posted this thread
Title: Re: How do I write to or change a specific part of a file?
Post by: ger21 on November 04, 2015, 11:36:32 AM
Goto?
Title: Re: How do I write to or change a specific part of a file?
Post by: Ya-Nvr-No on November 04, 2015, 12:24:44 PM
is this what your wanting?

x1 = getdro(0)
y1 = getdro(1)
z1 = getdro(2)
Print #1, "Here are the X, Y and Z coordinates"
Print #1, "My X = ", x1
Print #1, "My Y = ", y1
Print #1, "My Z = ", z1
Title: Re: How do I write to or change a specific part of a file?
Post by: BR549 on November 04, 2015, 12:29:49 PM
There are TONS of VB examples of this on the web (;-) That is how I learned it along with help from people like Craig and Ian.

(;-) TP
Title: Re: How do I write to or change a specific part of a file?
Post by: civilseal on November 05, 2015, 01:53:55 AM
is this what your wanting?

x1 = getdro(0)
y1 = getdro(1)
z1 = getdro(2)
Print #1, "Here are the X, Y and Z coordinates"
Print #1, "My X = ", x1
Print #1, "My Y = ", y1
Print #1, "My Z = ", z1

Thanks, bur how is this different from my example above?

My thought was that it must be an easy way to just tell it where to go in the file like
Print #1, X; row 10 or something like that but I can only find various to complicated ways to do it (at least for me) so there for I hoped that I missed something and that someone here new an easy way like my example.

ger21: How could I use Goto in this application?