Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
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!
Solved! Go to Solution.
Looking at your example I'd say you missed the commas:
Message find("Banana","na",1)
# results 3 12^
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^
Thanks, I thought it would be something I'd missed!