Jump to content
Macro Express Forums

joe

Members
  • Posts

    1,002
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by joe

  1. Hello Egan!

     

    Here is one solution ... although eloquent is in the eye of the beholder ;). This macro uses the O/S's DIR command to get the size of a disk drive and also the size of all files in a folder. Just change the variables to suit your situation. I have attached a playable mxe file.

    // T1=Drive, T2=Output file, T3=Output folder, T4=Input folder
    Variable Set String %T1% "c:\"
    Variable Set String %T2% "FreeSpace.txt"
    Variable Set String %T3% "c:\Temp"
    Variable Set String %T4% "c:\Pgm3"
    
    // If output file exists then ersae it
    If File Exists "%T2%"
     Delete File or Files: "%T2%"
    End If
    
    // Get the drive free space
    Program Launch: "cmd"
    Wait for File Exist: "%T2%"
    Wait for File Ready: "%T2%"
    
    // Scan for the "bytes free" line
    Text File Begin Process: "%T2%"
     If Variable %T5% contains "bytes free"
       Break
     End If
    Text File End Process
    
    // Extract the drive size to D1
    Replace "bytes free" with "" in %T5%
    Variable Modify String: Trim %T5%
    Variable Set Integer %N1% from Position of Text in Variable %T5%
    Variable Modify String: Delete Part of %T5%
    Variable Modify String: Trim %T5%
    Variable Modify String: Convert %T5% to decimal %D1%
    
    // Now get the sizes of the files within the input folder
    Delete File or Files: "%T2%"
    Program Launch: "cmd"
    Wait for File Exist: "%T2%"
    Wait for File Ready: "%T2%"
    
    // Scan for the "bytes free" line. Save the line number
    Variable Set Integer %N1% to 0
    Text File Begin Process: "%T2%"
     Variable Modify Integer: Inc (%N1%)
     If Variable %T5% contains "bytes free"
       Break
     End If
    Text File End Process
    
    // Extract the folder size to D2
    Variable Modify Integer: Dec (%N1%)
    Text File Begin Process: "%T2%"
    Text File End Process
    Replace "bytes" with "" in %T5%
    Variable Modify String: Trim %T5%
    Variable Set Integer %N1% from Position of Text in Variable %T5%
    Variable Modify String: Delete Part of %T5%
    Variable Modify String: Trim %T5%
    Variable Modify String: Convert %T5% to decimal %D2%
    Macro Return

    DriveAndFolderSizes.zip

  2. Hello Nicolas!

     

    There was a project that we had worked on a while ago. It required accessing and gathering data from approximately 20,000 web pages per month. It was run 24/7, which meant a new page every 30 seconds. There are four things that we did to make the waiting for web pages more reliable:

    1. We made sure that IE would check for a new page each time (Tools | Internet Settings | General | Settings)
    2. We would place the Wait for Web Page command immediately after the Web Site command. No pauses or delays of any kind between them. This prevented the Wait for Web Page command from missing the "okay" signal from the O/S (now the two commands can be command into one).
    3. We waited for the IE "progress bar" to finish by trapping for a change in pixel colors within a Repeat Loop.
    4. We placed a Delay of 1 second following the loop.

    We had actually set up two computers. One simply gathered the data using the above steps and saving it to a file, while the other processed the data. By taking these steps, we were able to get the macro to run reliably for a long period of time. I think the longest it ran was 10 days before memory leaks from Microsoft O/S froze the machine.

  3. Yes. Most, but not all, of the sections within a Macro Express command are a fixed length. This can look real strange for coordinate positioning fields, which will accept literal, variable, and text values:

    :000000:
    :000256:
    :00%N2%:
    :0%N88%:
    :Center:
    :Bottom:
    :000Top:

    are all six characters in length.

  4. Hello K_H!

     

    It sounds like you are wanting to create, or open, a .doc document and have it based on a particular .dot template. Clicking on the Word template (as you say) does this. But of course Word is already launched with the normal.dot template. Here is a link to an earlier topic that covered how to use Macro Express to launch Word along with a specified .dot template.

     

    Hope this helps!

  5. Hello Linda!

     

    The code doesn't look correct.

    <TEXTTYPE:<CTRLD>2<CTRLU>><WAITPB><PAUSE>

    It looks like, for whatever reason, there is an extra separator character (""). The command should look like this as viewed from the Direct Editor:

    <TEXTTYPE:<CTRLD>2<CTRLU>>

    Which would answer why it works okay after reentering the command. You could have also used the simpler form of:

    <TEXTTYPE:<CONTROL>2>

  6. Welcome Lon!

     

    Use the Change Directory/Folder command first. This will position you into your target folder.

    Change Directory/Folder: "c:\temp"
    Create Folder: "TestFolder"

    Use the Prompt for Value command within the Variable Set String dialog to store a folder name to a variable. The variable can then be used in place of a literal value. For example:

    Change Directory/Folder: "c:\temp"
    Variable Set String %T1% from Prompt
    Create Folder: "%T1%"

  7. Hello jmb4370!

     

    There is also a sample.mex library file in the Macro Express home folder that contains other macros that you can look at. A mex file is a library of individual files. An mxe file is just an individual macro that can be imported to, or exported from, a library. Macros are nothing more than text files.

     

    As to your other problem, post the macro that you are having trouble with to the forum so others can look at it and maybe see the problem.

  8. Hello cbv!

     

    You can run a batch file from Macro Express using the Program Launch command. In order to trap what your batch file outputs, have it create a file, in a known location, that is named something like 0.txt, or 1.txt, and so forth. Attached is a sample DOS batch file that simply creates a file named testout.txt when it is run. I've also attached a sample playable macro.

    Delay 250 Milliseconds
    Variable Set String %T1% "c:\pgm3\output\testout.bat"
    Variable Set String %T2% "c:\pgm3\output\testout.txt"
    If File Exists "%T2%"
     Delete File or Files: "%T2%"
     Delay 500 Milliseconds
    End If
    Program Launch: "%T1%"

    CreateFileUsingEcho.zip

  9. Hello ffortino!

     

    There are no arrays in Macro Express, but a linear sequence of variable numbers can be stepped through like an array. The following code stuffs string variables T1 through T99 with values from the Registry. Is this what you are thinking about? We do this in several areas of our PGM Functions Library.

    Repeat Start (Repeat 99 times)
     Read Registry String: "T%N1%"
    Repeat End

    And there are other sophisticated ways of handling variables such as using dynamic macros.

    VarLoop.zip

  10. Hello Thoughts!

     

    It is true that only a single macro can run at any given time, but maybe your macro tasks do not have to be continually running, leaving an opening for other macros to run. I was thinking that you might be able to create this first macro to run when no other keyboard or mouse activity is occurring. You would then be able to run other macros.

  11. Hello Paul!

     

    The Windows Registry is designed to store data; strings, integers, doubles, and other types of data. The Windows Notepad is a quick, simple, but handy text editor, which also uses the Registry to store its settings ... like almost every other piece of software on your computer.

  12. Hello conniek!

     

    Well, let's say that variable %N1% contains 500,000 then you would use the Variable Modify Integer command like so:

    Variable Modify Integer: %N2% = %N1% / 5000

    Is this what you are asking?

     

    Also, I am curious; is this Metroscan software using Visual Foxpro databases? I ask because you designated .dbf as the database extension.

×
×
  • Create New...