Jump to content
Macro Express Forums

Problem with Variables in File Copy Command


Recommended Posts

I am trying to copy a file from C:\McL\Scanned Documents\mclscan.pdf to C:\McL\Admin\Scans\%T[1]%.pdf where T1 is the name of a scanned document. When I do the copy, the end result is C:\McL\Admin\Scans\%T[1]% without the .pdf". Is this a bug in the Macro Express software or have I set up the variable syntax wrong. Also, what is the difference between T1 and T[1] I have used both interchangeably but this may be a problem.

Link to comment
Share on other sites

I would need to see how your variables are defined but %T[1]% appearing like that usually indicates it's not defined. Look in your variable list and ensure there's a string variable named "T" and that it is an array with at least one element.

 

 

 

In ME3 we only had one string array variable T. So the pointer, 1 in your example, needed no special delineation. But now that we have named variables that needed to change. So now the syntax has the square brackets. So you could create a brand new macro and have the array T defined with 99 elements and also define a variable T1. These are distinct. EG %T[1]% and %T1% can exist at the same time and be different. IE they are not interchangeable.

 

 

Link to comment
Share on other sites

Is this a bug in the Macro Express software or have I set up the variable syntax wrong.

You could use the debugger to step through your macro from within the Script Editor. Click Debug, Show Variable values to display the variables as you step through the macro. Or you can insert a Text Box Display command with "C:\McL\Admin\Scans\%T[1]%.pdf" in it to display the path.

 

what is the difference between T1 and T[1] I have used both interchangeably but this may be a problem.

T1 and T[1] are not the same variable. You can use either but do not expect them to contain the same thing. T1 is a variable containing a string. %T[1]% is part of an array variable. You access individual elements of the array with an index like %T[2]% or %T[%Idx%]%. Note that %Idx% is an integer variable in this case.

 

Instead of using T1 as a variable name you should consider using a name that reflects the purpose of that variable. You might use %NewFilepath%, for example.

Link to comment
Share on other sites

Or you can insert a Text Box Display command with "C:\McL\Admin\Scans\%T[1]%.pdf" in it to display the path.

I am trying to set up the text box display but the stay on screen option has 0 seconds in it and it is greyed out so I cannot change it. I can't make out what the variables are as it flashes up for a millisecond an then is gone. A workaround is that I set the text box to stay focused and on top and I put a basic timing pause after the text box command. How do I get the stay on screen option working?

Link to comment
Share on other sites

I am still having the problem that when the file is copied to the new location it looses the ".pdf" so it ends up in the Scans directory as an unknown file type. When I manually add the .pdf it works. But I don't understand why I loose the ".pdf" when I copy form one location to another location. Here is the syntax again. Copy File/Files: "C:\McL\Scanned Documents\mclscan.pdf" to "C:\McL\Business\Medikel\Scans\%T[1]%.pdf". %T[1]% is set to "scan Primacy Name Transfer Authorization" so the name of the file ought to be "scan Primacy Name Transfer Authorization.pdf" but I am missing the ".pdf" Is this a bug in the program?

Link to comment
Share on other sites

Did you read my post?

 

How about you post a sample of your macro so I can take a look at it. You can export this single macro to an MEX file. We need that so we can see how you defined your variables.

 

 

Link to comment
Share on other sites

  • 2 weeks later...

here it is! The copy command drops the ".pdf" after the variable, so I get a file with out an extenssion. a workaround was to have Adobe Acrobat open the file and then save it again. This gets me the pdf extension on the file.

Can you also include your mclscan.txt please?

Link to comment
Share on other sites

here it is

How could this ever work?

 

In the text file you attached is the value

"AGF Statement MCRM 2010", terminated with Carriage Return and Line Feed (x0D0A)

 

- You read this entire value into %T[9]%, then do several replacements of various characters, and finish by twice replacing 2 spaces with one

 

- You then append "pdf"

 

- Then you do a save and restore of all text variables, for reasons which escape me

 

- Finally you use this name, suffixed with .pdf, to copy an existing file to.

 

So, even if it worked, your new file would be called (without the quotes):

"AGF Statement MCRM 2010**pdf.pdf"

where ** represents CrLf.

 

I have little idea what you really want to do here.

 

BTW, you're not losing "pdf" (note you haven't included the period); it's simply that you can't see it because of the CrLf characters.

 

In case you don't follow me, look at the next 2 lines:

 

The quick brown fox

jumps over the lazy dog

 

After "fox" is CrLf, which you can't see, but which causes the line "jumps over..." to appear below and aligned with "The quick...". But just because you can't see it doesn't mean these characters are not present.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...