Hello Guest it is March 29, 2024, 12:53:39 AM

Author Topic: How do I write to or change a specific part of a file?  (Read 3845 times)

0 Members and 1 Guest are viewing this topic.

How do I write to or change a specific part of a file?
« 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?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How do I write to or change a specific part of a file?
« Reply #1 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
Re: How do I write to or change a specific part of a file?
« Reply #2 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

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: How do I write to or change a specific part of a file?
« Reply #3 on: November 04, 2015, 11:36:32 AM »
Goto?
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: How do I write to or change a specific part of a file?
« Reply #4 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

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How do I write to or change a specific part of a file?
« Reply #5 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
Re: How do I write to or change a specific part of a file?
« Reply #6 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?