cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How do the "batch" and "find" string function work?

TimSharp
6-Contributor

How do the "batch" and "find" string function work?

I've a macro that writes the date and drawing name to a text file, and I want to make a list of drawings with just a specific date.

I'm trying to use the batch command to get values from the text file but can't make it work.

Has anyone used this along with the "find" function to find a specific string within a line of a text file?

I've tried it a few ways so far and it either gives me an unknown macro command error, or it crashes Isodraw altogether - I obviously don't understand the syntax of the function or how to extract what it returns.

Do you make a variable of the character position that "find" gets?

Example text file (it's actually got more in than just the date and the drawing name) is:

10-03-2011,11:57,Tim Sharp,export cgm THA1003-291.cgm
10-03-2011,12:01,Tim Sharp,export cgm THA1003-297.cgm

11-03-2011,12:11,Tim Sharp,export cgm NPA79-170a.cgm

11-03-2011,12:12,Tim Sharp,export cgm NPA79-179.cgm

I want to find lines that have the current date (11-03-2011), then extract the drawing names (e.g. NPA79-170a.cgm) so I can write them into another file.

There will be duplicates in the file so I have to de-dupe them as well, but I'll come to that when I have the other bit done.

A little example of one that works would be invaluable!

1 ACCEPTED SOLUTION

Accepted Solutions

Looking at your example I'd say you missed the commas:
Message find("Banana","na",1)
# results 3 12^

View solution in original post

3 REPLIES 3
TimSharp
6-Contributor
(To:TimSharp)

I didn't include my macro the other day.

macro list-drawings not_in_menu

batch gl_macro_useage_ref_file_path "add-to-drawing-variable"

# gl_macro_useage_ref_file_path IS A GLOBAL MACRO

end macro

submacro add-to-drawing-variable (string current_line)

message current_line

# ABOVE DISPLAYS THIS SO BATCH COMMAND IS WORKING OK

define posn1 as float

posn1 = find (current_line gl_current_date 1)

# ABOVE GIVES AN "Unknown Macro Command" ERROR

end submacro

What have I got wrong?

Looking at your example I'd say you missed the commas:
Message find("Banana","na",1)
# results 3 12^

TimSharp
6-Contributor
(To:bgraffmann)

Thanks, I thought it would be something I'd missed!

Top Tags