Solved I need a vb script that can search a and replace header info

July 24, 2012 at 11:48:49
Specs: Windows 7
my master header file looks like this:
C.0079F053S95
C.0091F055S95
C.0100F060S95
C.0120F064S95
C.0125F069S95

my output file looks like this:
%
M48
T01C0.0100
T02C0.0240
T03C0.0330
T04C0.0350
T05C0.0400
T06C0.0550
T07C0.1280
VER,1
%
T01

I need the script to search the output file and update it with the master file data.


See More: I need a vb script that can search a and replace header info

Report •

#1
July 25, 2012 at 18:36:10
I think you need to give more information to get a response. Try to view the situation from perspective of the potential "helper". How would YOU answer, if someone posted:
I need to update my outputfile with my master file.

Report •

#2
July 29, 2012 at 12:45:21
Ok. I have a file with feeds and speeds in it that starts from the smallest size to the largest size. This is my master database.
Size Feed Speed
C.0079 F053 S95
C.0091 F055 S95
C.0100 F060 S95

I create/output an NC Drill file from my CAD software which has limited information in the header.
%
M48
T01C0.0100
T02C0.0240
T03C0.0330

What I am trying to do is run a script that searches my NC Dill file for the SIZE instance which starts with th 'C' and replaces the existing information with the information from the master file which his a more detailed description so it looks like this;
T01C.0100 F060 S95

Right now I cur the information from the master and paste it in to the NC Drill fie. There is a couple other things I need it to do which is delete the % at hte beginning of the file and after the M48 put in an X,Y offset which would read 'G92X0325Y0', This is 1 of 4 strings it could be.


Report •

#3
July 29, 2012 at 22:01:28
✔ Best Answer
much better explanation. Thanks. here is tentative. It WILL need work/debug/tweaked.

@echo off>drill.out & setlocal enabledelayedexpansion
>drill.out echo M48
:fixed better way: put your 4 coordinates into textfile. LEAVE FIRST LINE BLANK.
:use 1,2,3,4 to specify which one you want to use.
for /f "skip=%1" %%a in (coords) do >> drill.out echo %%a & goto :2
:2
:drillm is name for your master file
:load variables' names and two values into matrix
for /f "tokens=1-3" %%a in (drillm) do (
set x=%%a
set !x!=%%b%%c
)
:drill is name of your CAD outputfile
for /f "skip=2" %%a in (drill) do (
set test=%%a
set t0=!test:~0,3!
if /i !t0!" equ "ver" goto :done
set t1=!test:~3!
set t1=!t1:C0.=C.!
echo [!t0!][!t1!]
call :oo
)
goto :eof

:oo
if "!%t1%!" neq "" (
>>drill.out echo %t0%%t1%!%t1%!
)
goto :eof
:done
>>drill.out echo %%
:end


vbscript can do same thing, but I'm just lazy using batch for some things.


Report •

Related Solutions

#4
August 1, 2012 at 12:18:58
I am no expert at this for sure. Here is 2 mini files to look at. I appreciate your help.

Master.txt
---------------------------------------------
C.0079F053S95
C.0091F055S95
C.0100F060S95

12345.drl (my output file from CAD)
---------------------------------------------
%
M48
T01C0.0079
T02C0.0091
T03C0.0100
VER,1
%

12345.out (what I need it to look like)
----------------------------------------------------
M48
T01C.0079F053S95
T02C.0091F055S95
T03C.0100F060S95
%


Report •

#5
August 1, 2012 at 18:04:56
ok. I edited/fixed the script in reply #3 to reflect the latest data & specs you posted. I left the coordinates part in because originally you said you wanted that to follow the "M48" line. The script should run, as is, but to get the coordinates, you need to put them in a file, one per line, leaving the first line blank or dummy-data.
file "coords" looks like:
line 1: doesn't matter what you put here, it always gets skipped
G92X0325Y0
G92X0290Y0
G90X0Y0100
G99X0180Y0
-- eof --
then when you run the script, put the line# you want the coordinates from:
DRILL.BAT 2

script worked in my test simulator using data samples you gave.


Report •

Ask Question