May 13, 2024, 06:17:08 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Find / Replace help needed

Started by RitchieF, August 04, 2013, 08:19:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RitchieF

I'm working by profession as cnc operator. To simplify my work I'd like to write a program/simple IDE to do the following work:

I have a X/Y coordinates table with up to 300 lines of pairs of X/Y coordinates.
Now I'd like to create an editor where I write i.e.

N1 X#1 Y#1
N2 X#11 Y#11
N3 X#100 Y#100

and then after clicking an action button or hit the enter key the program should find / replace the X#1  / Y#1 with the appropriate value in the line number #1 found in the table .

How can I prevent the find/replace routine from replacing #11 or #100 but only #1 ?

Thanks for any help

Richard

LarryMc

Richard
I believe I can fix you up pretty easily if you give me an EXACT example.

the coordinates you say are in a table; where is the table and how do the values get there?
can x#1 appear in multiple lines of your editor file(like on line 1, 23, 132, etc or does it appear only once )?
i.e. is this valid:
n1 x1 y1
...
n23 x1 y1
...
n132 x1 y1

Is it always
x1 y1or can it be
x1 y3
If x and y always refer to the same line in your table why can't you just type
n1 3in your editor and have it replace the 3 with the two coordinate
values
Is the # actually needed or could you use this in your editor
n1 x1 y1
what are the N1,N2,etc doing for you?
I need an EXACT example of:
what you want to type(say 20 lines in a file)
what the coordinates in the table look like exactly in the table for those lines(in a file)
and EXACTLY what you want the final file to look like using the 2 above.

You said cnc and I'm thinking g codes and x y z coordinates so I want to be sure I give you what you really need without wasting a lot of time with trial and error.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RitchieF

Larry,

please find attached 2 files :

one with coords in csv format I have to write myself
one is a file I use in my control . It's original Haidenhain format.

Quotei.e. is this valid:
Code:

n1 x1 y1
...
n23 x1 y1
...
n132 x1 y1

YES

QuoteIs it always
Code:

x1 y1

YES

Richard

LarryMc

okay, that shows me what you are doing
I'll have a solution for you in a couple of hours or less
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc


I'm assuming you made some typos in your example/coordinate files
  L X#1 Y#1 F MAX
  L Z+2. F MAX
  CYCL CALL
  L X#2 Y#2 F MAX M89
  L X#3
  L X#4 Y#4
  L X#5 Y#5
  L X#6 Y#7  <--- mismatch - assume should be X#6 Y#6
  L X#8         <---should be x#7 to match coord file
  L X#9 Y#9  <---should be X#8 Y#8 to match coord file
                   <---should be x#9 to match coord file   
  L X#10       <---should be y#10 to match coord file
  L Y#11       <---should be x#11 to match coord file
  L X#12       <---should be X#12 Y#12 to match coord file

  L X#13 Y#13
  L X#14 Y#14 ; and so on
I'm making those corrections in you example.txt file
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RitchieF


LarryMc

Attached is your original coords.txt file, the corrected examples.txt file and an iwb file.
the iwb is an edit window with menu option to load a file, print it, save it, and change the font.
there is also a menu option to merge the example and cords files

The iwb is hard coded to open your file and save to on output.txt file
it is also hard coded to open the cords file.
if you comment those 3 lines out and uncomment those next to them you will trigger the open/save file dialog to pick your filenames

The whole thing relies heavily on the spaces in the gcode file
If you add or delete spaces it will cause problems.

I put multiple warning/abort messages in case I find mismatched or missing data when merging but I didn't spend any time chaecking them out.
you can do that; they're straight forward.

Sorry it took me longer than I said but you get that with us old farts some times.

Hope it all does what you want it to do.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RitchieF

Great work, Larry !

Wanted a glass of beer and got a whole barrel  ;D

Now have to play with it and see how it works.

Many thanks again !

Richard