Solved

Stepping through file...

Posted on 2000-05-09
6
139 Views
Last Modified: 2010-05-02
Hi guys,

I need to read a file line by line to get some test logins and passwords e.g line one is

login password

I'm posting this to a script in a form using Inet.execute, now here's the prob, it works fine, but what I need to know is how read one line, then process this to the form, then read the next line and process this to the form, etc etc, at the moment it's just looping through all the way to the last line and then only processing that line, if I try to include the inet.execute every loop it says the last process is still executing.

How I can I execute each line in the file? Furthermore, can I use a timer somehow to get this function to go through the file again after a certain period i.e after 1 second, after 30 seconds, etc? without having to click the command button again? Here;s my code, thanks for any help.

Private Sub cmdPOST_Click()
   picTic.Visible = True
   txtData.Text = ""
   
   Dim fnum As Integer
   Dim file_name As String
   Dim got_file As Boolean
   Dim txt As String
   
   Dim i As Integer
   Dim sArray As Variant
   
    ' Get the file's name.
    file_name = App.Path
    If Right$(file_name, 1) <> "\" Then file_name = file_name & "\"
    file_name = file_name & "logins.txt"
     
    ' Open the file.
    fnum = FreeFile
    On Error Resume Next
    Open file_name For Input As fnum
    got_file = (Err.Number = 0)
    On Error GoTo 0

    If got_file Then
        ' Read the text.
               Do Until EOF(fnum)
       
            Input #fnum, txt
            sArray = Split(txt)
            txtRemotePath.Text = "MNO=" & sArray(0) & "&PWD=" & sArray(1) _
            & "&BSB=NTV25"
     Loop
   Inet1.Execute txtURL.Text, "POST", txtRemotePath.Text, _
   "Content-Type: application/x-www-form-urlencoded"
   Text1.Text = Text1.Text & "yeah"
        ' Close the file.
    Close fnum
    End If
   
End Sub
0
Comment
Question by:GnatMan
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2795284
You can check the StillExecuting property to see if the control is busy with a earlier assignment. Perhaps you could implement a Do..Loop block after the Execute call like this

  'Place the Execute call here
  Do While Inet1.StillExecuting
    DoEvents
  Loop
  'The Inet control is free for next action here
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2795290
use the Line Input statement, e.g.
Line Input #FileNumber, A$

where filenumber is your file number and A is a string to receive the line from the file...then process that one line and perform the loop until EOF
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2795292
sorry i misread the question
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 28

Expert Comment

by:AzraSound
ID: 2795300
vbmaster is correct...you need to check that state...b/c when you use execute method it processes your request asynchronously which means it returns control back to your app right away...
0
 
LVL 7

Accepted Solution

by:
Vbmaster earned 23 total points
ID: 2795306
Just add a Timer control and set the Interval to 30000 (in case of 30 sec) or 60000 in case.. humm..

Inside the timer_timer event you can put code like...

  Private Sub Timer1_Timer

    Static Inside As Boolean
    If Inside Then Exit Sub
    Inside = True

    Call cmdPOST_Click()

    Inside = False

  End Sub

The static Inside varaible is probably really important here because sometimes maybe the cmdPost code will take more than 30sec (or whatever interval the timer is on) and you do not want two or more timer events to be executed simultaneous, that is just begging for trouble.

The Interval property of the Timer control is limited to 65535 ms, if you need a interval longer than 1 minute you can set the Interval to 60000 ms (1 minute) and then add a static counter inside the timer event. Increase the value with 1 every time the event is fired, and then if the timer equals the number of minutes you want to go between the calls to the code then set the variable to zero and run the cmdPOST code.
0
 

Author Comment

by:GnatMan
ID: 2795493
Thanks for all the help and the quick replies VBmaster and Azrasound, you guys are awesome! It really helped, got it working now. Cheers!
Nathan
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now