Spareman Posted July 12, 2012 Report Share Posted July 12, 2012 First off I'd like to apoligise if this has been answered before, but an hours google search came up with nothing. I am writing a macro to imrpove some instrumentaton in my lab (postgrad) and I need it to do the following basically, Run experiment (data is saved as Scan.txt) Take saved data and append the filename with a "1" e.g. Scan1.txt Run experiment again (new data set saved) Take saved data and append the filename with a "2" e.g. Scan2.txt etc. for about 100 iterations. I think my limited experience is good enough to complete the macro except for the writing of filenames. What I have so far is something along the lines of :- variable N1 is the iteration variable Repeat (Repeat 100 times) Run experiment Renamefile "Scan.txt" to "Scan + %N1% .txt" End repeat Thats basically all I need however the code needed for line 3 is completely lost on me. Any help would be greatly appreciated. Thanks, Shane Quote Link to comment Share on other sites More sharing options...
dcman98 Posted July 12, 2012 Report Share Posted July 12, 2012 Hi Shane, Although I'm no expert on this, I think that your problem is that the program sees N1 as a number, not as text. I did a little test myself, and could not get it to work as a number, but this did work. Before the rename step, insert this step: Variable Set String T1, choose Set Value Now, and for the value, put %N1%. Then change your rename step to use %T1% instead of %N1% (and lose the plus sign so it reads Scan%T1%.txt) This should do it for you. David edit: you may need to add a delay, or some query where it checks if the scan.txt file has been created. Otherwise, while the experiment is still running, the macro will move on and try to rename a file that isn't there yet. Quote Link to comment Share on other sites More sharing options...
paul Posted July 13, 2012 Report Share Posted July 13, 2012 If I understand your message correctly, you need %N1% to increment by 1 each time you use it. You can do this directly in the Repeat statement itself (you'll see something like "store the counter into a variable"), or by including the statement "Variable Modify Integer %n1%: Increment" within the Repeat loop. Quote Link to comment Share on other sites More sharing options...
Spareman Posted July 17, 2012 Author Report Share Posted July 17, 2012 Thank you for the help guys, seems like converting the int to a str will solve the issue! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.