>>
APLDN Home

>>
Events

>>
Trainings

>>
APL Books

>>
APLDN Links

>>
Discussion Groups

>>
Downloads

>>
Articles

>>
Library

>>
Learning Tools

>>
APLDN User IO

>>
APL2000.com




General

Author Thread: WebTransfer - trivial example
brent.hildebrand
WebTransfer - trivial example
Posted: Friday, May 07, 2004 5:29 PM (EST)

WebTransfer - very cool!  I had to try a very simple sample program.  Here is a User Command to determine your "real" Internet address using the website,  www.myip.com.   WebTransfer makes it simple.  This command shows the IP address of my wireless router which is my real IP address, not the IP address of my machine on the network.

 

    ’ CMDMYIIP A;a
[1]   a„'x' Œwi 'Create' 'APL2000.WebTransfer'
[2]   a„'x' Œwi 'XOpen' 'http://www.myip.com'
[3]   a„(Œio+1)œ'x' Œwi 'XSend' '' ''
[4]   a„3‡(Ÿ\a Œss 'is')/a
[5]   RESULT„(^\0=a Œss '<')/a

[6]   'x' Œwi 'Delete'
    ’

 

Saved to the user command file,  sample results:

 

      ]myiip
209.179.33.120

 

Question - is the WebTransfer.DLL all the is required to redistribute the Control and the .NET Framework?

 

 


Comments:

Author Thread:
davin.church
WebTransfer - trivial example
Posted: Friday, May 07, 2004 6:57 PM (EST)

That's cool.  I just tried the same thing with my APL-only HTTP function with the following results:

 

      5œ'< >' ‘cut 2œHTTP 'www.myip.com'
66.6.195.12

 

It's not packaged as a ]-cmd, but I found it to be quick and easy to create (and it didn't require any external DLLs or other configuration).

     

Jairo.Lopez
WebTransfer - trivial example
Posted: Friday, May 07, 2004 7:18 PM (EST)

Yes, the only requirements for the WebTransfer is the dll and the .Net Framework version 1.1.

Any ideasof how to implement user commands that take advantage of the Async functionality of WebTransfer?

     

brent.hildebrand
WebTransfer - trivial example
Posted: Friday, May 07, 2004 9:07 PM (EST)

Async User Command?  Is this a quiz?   Hm.

 

CMDAMYIIP A;a
a„'xMYIP' Œwi 'Create' 'APL2000.WebTransfer'
a„'xMYIP' Œwi 'XOpen' 'http://www.myip.com'
a„'fmMYIP' Œwi 'Create' 'Form' ('where' ¯1000 ¯1000 0 0)('style' 2)('border' 512)
'xMYIP' Œwi 'onXCompleteCallback' "'fmMYIP' Œwi 'value' ('xMYIP' Œwi 'xreturnedData') ª 0 0½'fmMYIP' Œwi 'Close'"
a„'xMYIP' Œwi 'XASend' '' ''
a„'fmMYIP' Œwi 'Wait'
0 0½'fmMYIP' Œwi 'Delete'
a„3‡(Ÿ\a Œss 'is')/a
RESULT„(^\0=a Œss '<')/a
'xMYIP' Œwi 'Delete'

 

Test it:

 

'Timer' Œwi 'Create' 'Timer' ('interval' 50)('onTimer' "'tic'") ª Œwgive 0 ª '#' Œwi 'Defer' "Œucmd 'amyiip' ª Œdl 5 ª 'Timer' Œwi 'Delete'"

 

Yes - it is asynchronous, but is it of value as a User Command?

     

brent.hildebrand
WebTransfer - trivial example
Posted: Friday, May 07, 2004 11:14 PM (EST)
With the command processor, when the code completes it execution, it gets cleaned out of the workspace.  The above example used a Wait on a Form to keep the code around until the asynchronous execution had completed, then the form was deleted and the remainder of the code executed, and finally cleanned up by the UC processor. 

     

j.merrill
WebTransfer - trivial example
Posted: Friday, May 07, 2004 11:41 PM (EST)
Sometimes it's nice for a UCMD to "hang out" -- but in this case, there's no good way for the information that's being requested to be displayed / returned to the caller. [line break goes here] Suppose a UCMD displays a form, puts any argument into an input field, and does some work when the user clicks a button on the form. If the UCMD does a Wait, then you're sort of stuck -- you can't keep on doing whatever you had been doing until you've cleared things. (And there's the bug that the UCMD will disappear from the stack if you run something, it suspends, and you do a naked branch to clear the suspension.) [line break goes here] If the UCMD does a Show, then exits, you can continue on; and the asynch mechanism would be useful there. However, in that case, you have to do something because any event-handler code needs to run without the CMDxxx function being in the ws any more! It's possible to deal with that, by sticking the #VR of the CMDxxx fn (or whatever fn is needed to handle callbacks etc) in a UDP on the form and making all the event handlers do a #DEF of the UDP contents if the needed fn isn't in the ws, before calling the fn. [line break goes here] It's possible to just Show forms in a UCMD, but it's a PITA.

     

brent.hildebrand
WebTransfer - trivial example
Posted: Thursday, June 03, 2004 4:32 PM (EST)

www.myip.com no longer seems to work for me.  So, here is an alternate site.

 

    ’ CMDMYIIP A;a
[1]   a„'x' Œwi 'Create' 'APL2000.WebTransfer'
[2]   a„'x' Œwi 'XOpen' 'http://www.showmyip.com'
[3]   a„(Œio+1)œ'x' Œwi 'XSend' '/simple' ''
[4]   ©a„3‡(Ÿ\a Œss 'is')/a
[5]   RESULT„(^\0=a Œss ' ')/a
[6]   'x' Œwi 'Delete'
    ’
      ]myiip
209.179.199.141

     



APL2000 Official Web Site

Love sought is good, but given unsought is better.
--- Shakespeare

APLDN Home   |    |  Events   |  Trainings   |  APL Books   |  APLDN Links   |    |  Discussion Groups   |    |  Downloads   |  Articles   |  Library   |  Learning Tools   |  APLDN User IO   |  APL2000.com   |