Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

proxy connection in alpha

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    proxy connection in alpha

    Question:
    Is there a way to set up a proxy connection in alpha

    Problem:
    I want to use the "a5_downloadfile" function but my internet connection is though a proxy so the function is not being able to connect to any external internet pages (outside intanet) eg.
    a5_downloadfile("www.google.com", "c:\google.txt")
    Cheers
    Mauricio


    #2
    Re: proxy connection in alpha

    Check out: HTTP_GET_PAGE2()


    Also there is API where you can access this info directly and use OLE for it to work with Alpha.

    http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx


    I am having some trouble with this though, maybe someone can help me finish it.

    Code:
    'Create a Pointer for the WinHTTP object and then create the object
    DIM objHTTP as P
    objHTTP = ole.Create("WinHttp.WinHttpRequest.5.1")
    
    'Set your proxcy here, you can also set urls to bypass the proxy
    'option 2 says to use this address as your proxy for this connection
    'objHTTP.SetProxy(2,"192.168.10.1:8080","")
    
    'open and request a url
    objHTTP.Open("GET","http://www.irs.gov/pub/irs-pdf/fw4.pdf",.F.)
    objHTTP.Send()
    
    'Create a file
    DIM file_pointer as P
    file_pointer = file.create("D:\W-4.txt", FILE_RW_EXCLUSIVE)
    
    'This is where the trouble is, "objHTTP.ResponseBody" is not a character, its a string of bytes
    'I don't know how to write this to a file without screwing it up if it doesn't contain a character
    DIM fileResponseBody as C = ""
    fileResponseBody = objHTTP.ResponseBody
    file_pointer.write(fileResponseBody)
    
    'Clean everything up
    'The WinHTTP object cleans itself up so you only have to delete the pointer
    file_pointer.flush()
    file_pointer.close()
    delete objHTTP

    Comment


      #3
      Re: proxy connection in alpha

      I guess if I did a little more research before I posted I would have completed it.

      I didn't know there was a .writeB() function to write a blob of data.

      So here is the working code to download any file, use a proxy or even download multiple files at the same time asynchronously if you want.

      I left out the error checking, but if you go to the msdn site listed in the previous post, you can see all the attributes you can check to see if everything went okay.

      Code:
      DIM myDownload as C = ""
      DIM myFile as C = ""
      myDownload = "http://www.irs.gov/pub/irs-pdf/fw4.pdf"
      myFile = "D:\W-4.pdf"
      
      'Create a Pointer for the WinHTTP object and then create the object
      DIM objHTTP as P
      objHTTP = ole.Create("WinHttp.WinHttpRequest.5.1")
      
      'Set your proxcy here, you can also set urls to bypass the proxy
      'option 2 says to use this address as your proxy for this connection
      'objHTTP.SetProxy(2,"192.168.10.1:8080","")
      
      'open and request a url
      objHTTP.Open("GET",myDownload,.F.)
      objHTTP.Send()
      
      'Create a file and write to it
      DIM file_pointer as P
      file_pointer = file.create(myFile, FILE_RW_EXCLUSIVE)
      if file.exists(myFile)
      	file_pointer.writeb(objHTTP.ResponseBody)
      else
      	'file not found
      	ui_msg_box("Error","Could not create file on disk.")
      end if
      
      'Clean everything up
      'The WinHTTP object cleans itself up so you only have to delete the pointer
      file_pointer.flush()
      file_pointer.close()
      delete objHTTP
      Last edited by jdrake; 04-06-2010, 10:06 AM. Reason: Fix code

      Comment


        #4
        Re: proxy connection in alpha

        thank you Jay ill try that and post my results
        Cheers
        Mauricio

        Comment


          #5
          Re: proxy connection in alpha

          http_get_page2 works great, since it takes IE settings It uses the proxy address that is defined on IE

          Thank you very much
          Cheers
          Mauricio

          Comment


            #6
            Re: proxy connection in alpha

            The problem I had with http_get_page2 is that you might not get all the data if there is a non-printable character in what your downloading.

            For example: try ?HTTP_GET_PAGE2("www.google.com")

            then try
            Code:
            DIM myDownload as C = ""
            DIM myFile as C = ""
            myDownload = "http://www.google.com/"
            myFile = "D:\google.txt"
            
            'Create a Pointer for the WinHTTP object and then create the object
            DIM objHTTP as P
            objHTTP = ole.Create("WinHttp.WinHttpRequest.5.1")
            
            'Set your proxcy here, you can also set urls to bypass the proxy
            'option 2 says to use this address as your proxy for this connection
            'objHTTP.SetProxy(2,"192.168.10.1:8080","")
            
            'open and request a url
            objHTTP.Open("GET",myDownload,.F.)
            objHTTP.Send()
            
            'Create a file and write to it
            DIM file_pointer as P
            file_pointer = file.create(myFile, FILE_RW_EXCLUSIVE)
            if file.exists(myFile)
            	file_pointer.writeb(objHTTP.ResponseBody)
            else
            	'file not found
            	ui_msg_box("Error","Could not create file on disk.")
            end if
            
            'Clean everything up
            'The WinHTTP object cleans itself up so you only have to delete the pointer
            file_pointer.flush()
            file_pointer.close()
            delete objHTTP
            You will see that a large piece of data is missing in HTTP_GET_PAGE2()

            So be careful in that respect.

            Comment


              #7
              Re: proxy connection in alpha

              Internet Explorer stores it's proxy settings in the registry. Therefore, they can easily be read into this script.

              This script use Internet Explorer's Proxy settings

              Code:
              DIM myDownload as C = ""
              DIM myFile as C = ""
              myDownload = "http://www.google.com"
              myFile = "D:\google.txt"
              
              'Create a Pointer for the WinHTTP object and then create the object
              DIM objHTTP as P
              objHTTP = ole.Create("WinHttp.WinHttpRequest.5.1")
              
              'Set your proxy here, you can also set urls to bypass the proxy
              'option 2 says to use this address as your proxy for this connection
              'This will lookup the Proxy settings from Internet Explorer
              DIM proxyOn as C = ""
              DIM proxyAddress as C = ""
              DIM proxyBypassAddress as C = ""
              
              proxyOn = registry.sys_get("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable")
              proxyAddress = stritran(word(registry.sys_get("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"),1,";"),"http=")
              proxyBypassAddress = registry.sys_get("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyOverride")
              
              if proxyOn = "1" then
              	objHTTP.SetProxy(2,proxyAddress,proxyBypassAddress)
              else
              	objHTTP.SetProxy(1)
              end if
              
              'open and request a url
              objHTTP.Open("GET",myDownload,.F.)
              objHTTP.Send()
              
              'Create a file and write to it
              DIM file_pointer as P
              file_pointer = file.create(myFile, FILE_RW_EXCLUSIVE)
              if file.exists(myFile)
              	file_pointer.writeb(objHTTP.ResponseBody)
              else
              	'file not found
              	ui_msg_box("Error","Could not create file on disk.")
              end if
              
              'Clean everything up
              'The WinHTTP object cleans itself up so you only have to delete the pointer
              file_pointer.flush()
              file_pointer.close()
              delete objHTTP

              Comment


                #8
                Re: proxy connection in alpha

                Hi Jay,

                Originally posted by jdrake View Post
                The problem I had with http_get_page2 is that you might not get all the data if there is a non-printable character in what your downloading.

                For example: try ?HTTP_GET_PAGE2("www.google.com")
                Don't confuse the results in the interactive window with the return data. If the return has an ascii null (chr(0)) in it (which it doesn't), it will show the result as a hex dump. Otherwise, it will show it as ASCII, including non-printable characters typically shown as boxes. Also, the Interactive window has a length limit for the entire window, after which it will truncate the text. If instead, you use
                Save_to_file(HTTP_GET_PAGE2("www.google.com"),"C:\google1.txt")
                Check the results which I got 11k bytes and compare to your code's objHTTP.ResponseBody, which I got 7k for.

                Alpha can return any string that does not have embedded ascii nulls in it, even with high order bits set and any length.
                Regards,

                Ira J. Perlow
                Computer Systems Design


                CSDA A5 Products
                New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                CSDA Barcode Functions

                CSDA Code Utility
                CSDA Screen Capture


                Comment


                  #9
                  Re: proxy connection in alpha

                  Originally posted by csda1 View Post
                  Hi Jay,



                  Don't confuse the results in the interactive window with the return data. If the return has an ascii null (chr(0)) in it (which it doesn't), it will show the result as a hex dump. Otherwise, it will show it as ASCII, including non-printable characters typically shown as boxes. Also, the Interactive window has a length limit for the entire window, after which it will truncate the text. If instead, you use
                  Save_to_file(HTTP_GET_PAGE2("www.google.com"),"C:\google1.txt")
                  Check the results which I got 11k bytes and compare to your code's objHTTP.ResponseBody, which I got 7k for.

                  Alpha can return any string that does not have embedded ascii nulls in it, even with high order bits set and any length.

                  How I originally came across it, I was trying to download a pdf and I couldn't get it to download through a proxy.

                  Try this:
                  Save_to_file(HTTP_GET_PAGE2("http://www.irs.gov/pub/irs-pdf/fw4.pdf"),"C:\test.pdf")

                  It gets all hung up around non-printable characters.

                  Comment

                  Working...
                  X