Jump to content
Macro Express Forums

wtawta

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by wtawta

  1. Here is what I understand about what you are trying to do.

     

    1. Another process creates a file with email addresses and passwords.

    2. Perform an action on the first email address/password pair.

    3. Remove that email address/password pair from the file.

    4. Repeat the same process sometime later.

     

    There is an easy way, even in Macro Express 3, to get values from a record that are comma separated using the ASCII Text File Begin/End Process commands. To get only the first record you can break out of the loop. Like this:

    // Read one line from the input file
    ASCII File Begin Process: "test.txt" (Comma Delimited Text )
     Break
    ASCII File End Process
    
    // Here T1= email address, T2= password

     

    The only way to remove something from the top of a file is to read the file and rewrite it. One seeming exception to this is if you are using a database program but in that case the database program leaves a hole in the data and ignores it. A pack or compression routine later rewrites the file or data to remove holes.

     

    To remove the first record from a file you read every record from the file, write all but the first record to a temporary output file and then rename the files. Like this:

    // Delete temporary output file if it exists
    If File Exists "test.txt"
     Delete File or Files: "testOUT.txt"
    End If
    
    // Read every record except record 1 from test.txt and write it to testOUT.txt
    Wait for File Ready: "test.txt"
    Text File Begin Process: "test.txt"
     Variable Set Integer %N1% to 1
     If Variable %N1% = 1
    Variable Modify Integer: Inc (%N1%)
     Else
    Variable Modify String: Append %T1% to Text File
     End If
    Text File End Process
    
    // Delete old backup file if it exists
    If File Exists "test.txt"
     Delete File or Files: "testBACK.txt"
    End If
    
    // Rename test.txt to testBACK.txt and testOUT.txt to test.txt
    Rename File or Files: "test.txt"
    Rename File or Files: "testOUT.txt"

     

    You may need to do something that tells the process that is adding email address/password pairs to the file to pause for a moment. You can add things to your macro that the other process reads to do this. (Since we have no idea what process is adding email address/passwords to the file there is nothing in this sample to accommodate that.

     

    Here is the sample macro in a form you can copy and paste into your own macro:

    <REM2:Read one line from the input file><ADFBEG:F10:001:000001:000000:c:\test.txt><BREAK><ADFEND><REM2:><REM2:Delete temporary output file if it exists><IFOTH:01:2:c:\test.txt><DOFILE:08:NN:testOUT.txt>><ENDIF><REM2:><REM2:Read every record except record 1 from test.txt and write it to testOUT.txt><WFREADY:000001:000000:000002c:\test.txt><BTFBEG:001:000001:000000:c:\test.txt><IVAR2:01:01:1><IFVAR2:2:01:1:1><NMVAR:08:01:0:0000001:0:0000000><ELSE><TMVAR2:20:01:00:000:000:c:\testOUT.txtT><ENDIF><BTFEND><REM2:><REM2:Delete old backup file if it exists><IFOTH:01:2:c:\test.txt><DOFILE:08:NN:testBACK.txt>><ENDIF><REM2:><REM2:Rename test.txt to testBACK.txt and testOUT.txt to test.txt><DOFILE:06:NN:c:\test.txt>c:\testBACK.txt><DOFILE:06:NN:testOUT.txt>test.txt>

    Kevin, I tried to use this sample you provided and failed to get it to work. I was left with the 'testBACK.txt' file in the C drive and not the 'test.txt' file. I took a look into the commands and noticed that there were some file paths missing. For example, in some of the file path fields it reads 'test.txt' instead of 'c:\test.txt'.

     

    I am assuming this was an oversight so I added the file path to the appropriate areas of the macro. For some reason I am not ending up with the desired result intended (I think). I believe the desired result of your macro is a 'test.txt' file with all the email/pass pairs minus the first pair in the original list. Instead, I am ending up with a 'testBACK.txt' file with all the original email/pass pairs. Nothing removed from the original document and no 'test.txt' file.

     

    Am I missing something?

  2. Another approach you might want to try is to leave the email address/passwords in the file and have your macro ignore them. Something like this would work:

    // Set N1 to the first value you want to read from the file
    
    // Read one line from the input file
    ASCII File Begin Process: "test.txt" (Comma Delimited Text )
     Break
    ASCII File End Process

    This example does not show how to keep track of the number to use. Look at samples.mex for the macro 'Counter_From_Run_To_Run' for a way to save a counter at the end of the macro and read it at the beginning of the macro. Samples.mex can be found in the folder where your Macro Express Program files are installed.

     

    If you decide to use this approach you could write a separate macro based on my other post to delete things from the email address/password file at a later time when it is safe to do so.

    Kevin, thanks for taking time to help. This is how we currently keep track of which email/pass pair is next in line to be used. We would like to change this method in order to keep this list clean (free of used pairs).

  3. "Then we will call for the first email/pass..." ??

    If you mean, "Get and process T1 and T2 for line 1 of the text file", then the macro I posted does that. There's no need to do any 'moving' etc. Whatever it is you want to do with T1 and T2, that is done automatically for each line where I showed the Text Display command. Read Help > Index > Text File Process if you need further clarification.

     

    --

    Terry, East Grinstead, UK

    It is necessary for this 'moving' to occur if this is to work in my project. I could give a explanation why but it would probably take me a day. lol. "Get and process T1 and T2 for line 1 of the text file" makes sense and works perfectly. I have edited the macro you posted a bit to just get and process T1 and T2 for line 1 of the text file and not to loop and process the rest of the lines. The next time I run this new macro it will process line 1 again and return the same information for T1 and T2 unless I can remove the original data of line 1, in this case T1 and T2 from the original text document. I can't (would rather not) keep track of which lines have been processed before hand, in order to get the next email/pass the next time I run this macro.

     

    I guess what I need to know are two things. How to delete the first line of text from a document, in this example an email address and password. I am assuming deleting this email/pass will leave a empty space in line 1 of the text document. If this is the case, the second thing I would need is to move the next email/pass up to the top (line 1) of the text document. Now, the next time the macro is run it will get a and process the T1 an T2 for line 1 and it will return the new values (email/pass) that were not returned the last time I ran the macro.

     

    I hope I am making sense. Thanks so much.

  4. Your description about replacing line 1 with line 2 is unclear to me. If it's meant to be repetitive, then it seems you'll end up with just a single line, the last!

     

    Terry, my partner "webbhogg" is the original poster of the thread. Thanks for you assistance, you answered something we've been trying to wrap our heads around for a while. :D

     

    Let me try to clear up what was meant by replacing line 1 with line 2. We will be processing the file and capturing the email /password one at a time. After we have the first email/pass we would like to remove it from the .txt file and bring the next email/pass up to line value 1. This way whenever the we need to get the next email/pass it will always be located on the first line (line value 1) of the text document.

     

    For example the text document may start with this data:

     

    name1@email.com:pass1 <--- (Line value = 1 of text doc.)

    name2@email.com:pass2

    name3@email.com:pass3

    name4@email.com:pass4

    name5@email.com:pass5

     

    Then we will call for the first email/pass leaving the text document like this:

     

    name2@email.com:pass2 <--- (Line value = 1 of text doc.)

    name3@email.com:pass3

    name4@email.com:pass4

    name5@email.com:pass5

     

    and, so on:

     

    name3@email.com:pass3 <--- (Line value = 1 of text doc.)

    name4@email.com:pass4

    name5@email.com:pass5

     

    I hope this is clearer. Please let me know and thanks again for you help!

  5. Can't seem to wrap my head around making this work the way I want. Simple for some of you so I hope you can help?

     

    I want to run a macro every "X" occurances of an event. Let me try to explain in more detail and as simply as I can. Every "5" times a "Notepad" window is opened I want to run my macro. I would like to be able to change the number from 5 to whatever number I want of course.

     

    So I'm thinking that every time Notepad is opened, one macro is counting each event and logging it in a variable and everytime that veriable equals my number, in this case "5", another macro is triggered??? If I'm on the right track so far then I realize that my triggered macro will need to reset that veriable from 5 back to zero somehow in order to repeat the after another 5 instances.

     

    Hope this makes sense and you can help me out.

×
×
  • Create New...