Jump to content
Macro Express Forums

floyd

Members
  • Posts

    292
  • Joined

  • Last visited

Posts posted by floyd

  1. ... but I didn't think or pairing the two up. Good advice.
    Maybe it is good advice. Others might do it differently. Some may think that both commands are not needed. I know, however, that this always works for me.
    I think one can reanme a file and in effect also move it to another folder and even have it create to folder structure
    Yes, you can.
    but it appears that it only works if it's on the same volume.
    Not true. It works just fine across volumes and networks.
    I was hopng for some clue as to when I could just use rename or move and when I had to do Rename, create directory, move.
    Both systems work. It is just a matter of choice.
  2. Try using the Wait for File Exist and then Wait for File Ready commands after the Rename File or Files command.

    Rename File or Files: "original.txt"
    Wait for File Exist: "copyof.txt"
    Wait for File Ready: "copyof.txt"

    Set the file Must be Ready for XXX Seconds field (in the Wait for file Ready command) for maybe 1 or 2 seconds if you are renaming large files. This tells Macro Express to continue waiting until Windows has not written anything to the file for the specified time period.

     

    Keep in mind that renaming a file can be fast or slow depending on where it is being moved and renamed to. If all action is to take place within the same partition on your drive then Windows does not actually do anything other than changing the internal index of where the file is. On the other hand, if the action spans a second drive, partition, or network, then Windows must physically move the file, which will take longer. Hence the need for the Wait for File Ready command.

  3. Bob -

     

    Thanks for the input.

     

    Opening and closing windows: The target macro that gets generated does not close any IE windows when it is fired. This is only done by the {Generate an Internet Login} function as you are creating the target macro. When you stated

    When I tested it with another window
    did you mean another IE window or any window?

     

    Acct and PIN fields: I think the problem may be that there is no HTML <INPUT TYPE=PASSWORD> type field. Currently this data mining macro works only if there is at least one <INPUT TYPE=TEXT> and <INPUT TYPE=PASSWORD> field. I will look further into this.

  4. Here is a sample using the {String - Parse} function:

     

    Variable Set String %T1% "\\server\share\dir1\dir2\dir3\dir4\last, first 333-22-4444.pdf"
    Variable Set String %T2% "\"
    Write Registry String: "ParameterString1"
    Write Registry String: "ParameterString2"
    Macro Run: { String - Parse }
    Read Registry Integer: "ReturnInteger1"
    
    Activate or Launch: "notepad" OR "notepad.exe"
    Wait For Window Title: "notepad"
    
    Repeat with Variable using %N1%
     Read Registry String: "Token%N2%"
     Text Type: Token %N2% = %T1%<ENTER>
    Repeat End
    
    
    <TVAR2:01:01:\\server\share\dir1\dir2\dir3\dir4\last, first 333-22-4444.pdf><TVAR2:02:01:\><REGWSTR:1:HKEY_CURRENT_USER\Software\Professional Grade Macros\Parameters\ParameterString1><REGWSTR:2:HKEY_CURRENT_USER\Software\Professional Grade Macros\Parameters\ParameterString2><MACRUN2:{ String - Parse }><REGRINT:1:HKEY_CURRENT_USER\Software\Professional Grade Macros\Parameters\ReturnInteger1><REM2:><LAUNCHYES3:0:0112notepad<LAUNCH:notepad.exe><WAITWIN2:000010:000000:notepad><REM2:><REP3:05:000001:000001:0001:1:02:><REGRSTR:1:HKEY_CURRENT_USER\Software\Professional Grade Macros\Parsed Tokens\Token%N2%><TEXTTYPE:Token %N2% = %T1%<ENTER>><ENDREP>

    All that you need to do is set a Registry value with the string-to-be-parsed and another Registry value to the character (or string) used as the parsing delimiter. Now call the {String - Parse} function, then read the number of parsed strings (tokens) that were generated.

  5. In addition to Randall's solution, you could look into the If Message/Else/End If construct and use it in place of the Multiple Choice Menu command.

    Repeat Until %N1% <> %N1%
     Delay 1 Seconds
     If Message: ""
       Repeat Exit
     Else
     End If
    Repeat End
    
    <REP3:08:000002:000002:0001:1:01:N1><IDELAY:1><IFMESS3:00000:1:1:
                                  OKAY TO EXIT LOOP?Center:Center><EXITREP><ELSE><ENDIF><ENDREP>

  6. Nicolas has it right. Here is an example that you can run:

    // Set the counter (placeholder for the next string).
    Variable Set Integer %N10% to 10
    
    // Infinite loop
    Repeat Until %N1% <> %N1%
     
     // Increment the next string placeholder (T11 through T46)
     Variable Modify Integer: Inc (%N10%)
     
     // Set a string to a random character to use as an example.
     // This would actually be a string that holds this month's data.
     Variable Set String %T1% to Random Letter
     
     // Exit the loop if the random character is a "Z" or if we have filled 36 string variables
     // This would actually be: Exit if no more months found or if we have gone back 36 months.
     If Variable %T1% = "Z"
       OR
     If Variable %N10% > 46
       Repeat Exit
     End If
     
     // Copy the current string to the next placeholder string
     Variable Set String %T2% "<TMVAR2:09:%N10%:01:000:000:>"
     Run Macro in Variable %T2%
     
    Repeat End
    
    
    <REM2:Set the counter (placeholder for the next string).><IVAR2:10:01:10><REM2:><REM2:Infinite loop><REP3:08:000002:000002:0001:1:01:N1><REM2:><REM2:Increment the next string placeholder (T11 through T46)><NMVAR:08:10:0:0000001:0:0000000><REM2:><REM2:Set a string to a random character to use as an example.><REM2:This would actually be a string that holds this month's data.><TVAR2:01:12:><REM2:><REM2:Exit the loop if the random character is a "Z" or if we have filled 36 string variables><REM2:This would actually be: Exit if no more months found or if we have gone back 36 months.><IFVAR2:1:01:1:TZ><OR><IFVAR2:2:10:4:T46><EXITREP><ENDIF><REM2:><REM2:Copy the current string to the next placeholder string><TVAR2:02:01:<TMVAR2:09:%N10%:01:000:000:>><RUNMACVAR:2><REM2:><ENDREP>

  7. Leading zeros are a common problem with any language. Here is one solution using Macro Express:

    // Original string
    Variable Set String %T1% "002"
    
    // Convert to an integer
    Variable Modify String: Convert %T1% to integer %N1%
    
    // Add 1001 to it
    Variable Modify Integer: %N1% = %N1% + 1001
    
    // Convert it back to a string
    Variable Modify Integer: Convert %N1% to text string %T1%
    
    // Delete the first character. Result = "003"
    Variable Modify String: Delete Part of %T1%
    
    <REM2:Original string><TVAR2:01:01:002><REM2:><REM2:Convert to an integer><TMVAR2:05:01:01:000:000:><REM2:><REM2:Add 1001 to it><NMVAR:01:01:1:0000001:2:0001001><REM2:><REM2:Convert it back to a string><NMVAR:05:01:0:0000001:0:0000000><REM2:><REM2:Delete the first character. Result = "003"><TMVAR2:11:01:00:001:001:>

  8. Cyberchief -

     

    The only difference between the source and non-source code PGM Functions Library is that with the former, you can view the code for all but the PGM System and Variable Management functions. Both libraries have the same number of macro functions and both do the same exact thing.

     

    The source-code version was never meant to be multi-licensed. Its only purpose was to allow interested parties to see some very nice Macro Express coding and perhaps to use some style of it in their own macros. If you purchase multi-licensed non-source code versions, Joe may be more than happy to give you a source code version.

     

    The PGM Functions Library is licensed in the same manner as Macro Express, which is on a per seat (machine) basis. One machine = one license. The more licenses you buy the less it costs per machine. For example, a single user PGM Functions Library license is normally $29.95, a 10-seat license is $20.90 per seat, a 20 seat license is $16.36 per seat, 100 seats is $8.29 per seat, and so forth.

     

    Email joe@pgmacros.com directly to discuss pricing ... he can help.

     

    The PGM Functions Library is just that. A library of ready-made functions that begins where Macro Express leaves off. You may not need or ever use all of them, just like we will never use all of the commands within Macro Express. You can pick and choose which functions to use and place in your own macro library (.mex) files so that you can keep "all machines the same" as you mentioned.

  9. Cyberchief -

    Here is your solution using Julian Date functions from the PGM Functions Library:

    // ASSUMPTIONS:
    // Today is May-04-2005
    // Account #1 has a billing date of May-15-2005
    // Account #2 has a billing date of May-09-2005
    
    // DEFINED VARIABLES:
    // D1 = Today's date
    // D2 = Bill date for account #1
    // D3 = First bad date for account #1 (bill date - 3)
    // D4 = Last bad date for account #1 (bill date + 5)
    // D5 = Bill date for account #2
    // D6 = First bad date for account #2 (bill date - 3)
    // D7 = Last bad date for account #2 (bill date + 5)
    // D8 = The correct date (the answer)
    
    // Save today's date to a variable (D1) and then convert it to a Julian day.
    Variable Set String %T1% "20050504"
    Write Registry String: "ParameterString1"
    Macro Run: { DateTime - Date to Julian }
    Read Registry Decimal: "ReturnDecimal1"
    
    // Convert the billing date to a Julian day (D2) for account #1.
    Variable Set String %T1% "20050515"
    Write Registry String: "ParameterString1"
    Macro Run: { DateTime - Date to Julian }
    Read Registry Decimal: "ReturnDecimal1"
    
    // Subtract 3 to get the first bad date within the billing range and then add 5 to get the last
    // bad date.
    Variable Modify Decimal: %D3% = %D2% - 3
    Variable Modify Decimal: %D4% = %D2% + 5
    
    // Convert the billing date to a Julian day (D5) for account #2.
    Variable Set String %T1% "20050509"
    Write Registry String: "ParameterString1"
    Macro Run: { DateTime - Date to Julian }
    Read Registry Decimal: "ReturnDecimal1"
    
    // Subtract 3 to get the first bad date within the billing range and then add 5 to get the last
    // bad date.
    Variable Modify Decimal: %D6% = %D5% - 3
    Variable Modify Decimal: %D7% = %D5% + 5
    
    // Copy today's variable (D1) to the answer variable (D8) then add 2 days to it before starting
    // the loop.
    Variable Modify Decimal: Copy %D1% to %D8%
    Variable Modify Decimal: %D8% = %D8% + 2
    
    // Loop by incrementing the answer variable by 1 each time until we find a good date. Check if
    // the variable falls within either date range. If it does then we need to increment, otherwise
    // we have the answer so exit.
    Repeat Until %N1% <> %N1%
     If Variable %D8% >= variable %D3%
       AND
     If Variable %D8% <= variable %D4%
       Variable Modify Decimal: %D8% = %D8% + 1
     Else
       If Variable %D8% >= variable %D6%
         AND
       If Variable %D8% <= variable %D7%
         Variable Modify Decimal: %D8% = %D8% + 1
       Else
         Repeat Exit
       End If
     End If
    Repeat End
    
    // Convert the (D8) Julian day answer variable to a date string (T2).
    Write Registry Decimal: "ParameterDecimal1"
    Macro Run: { DateTime - Julian to Date }
    Read Registry String: "ReturnString1"
    
    Macro Return

    The example should be easy to follow. However, you must have a copy of the PGM Functions Library in order to run it. A 30-day trial can be downloaded from PGM Functions Library and Docs.

     

    Hope this helps.

    JulianDate.mxe

×
×
  • Create New...