Home AMX User Forum NetLinx Studio

GET_URL_LIST with code?

I'm trying to get the list of IP addresses with the GET_URL_LIST function, but I'm not having any luck other than to get the number of URL's in the list. I'm able to use the ADD_URL_ENTRY function with no problem but I'm at a loss as to the correct coding to use. Any suggestions would be appreciated.

Comments

  • viningvining Posts: 4,368
    Did you create a structure IAW the format shown in the help file?

    Show the code.
  • rdriederrdrieder Posts: 25
    GET_URL_LIST with code?

    Isn't the structure defined in the netlinx.axi file?
    Here's the code...
    DEFINE_DEVICE
    
    dvMASTER = 0:0:0
    
    dvTP	= 10001:1:0
    
    (***********************************************************)
    (*               VARIABLE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_VARIABLE
    
    	// FROM NETLINX.AXI FILE
    
    //STRUCTURE URL_STRUCT
    //{
    //  CHAR     Flags;           // Connection Type (normally 1)
    //  INTEGER  Port;            // TCP port (normally 1319)
    //  CHAR     URL[128];        // string: URL or IP address
    //  CHAR     User[20];        // optional account info for ICSPS Added v1.21
    //  CHAR     Password[20];    // optional account info for ICSPS Added v1.21
    //}
    
    VOLATILE URL_STRUCT UrlList[24]
    
    (***********************************************************)
    (*                THE EVENTS GO BELOW                      *)
    (***********************************************************)
    DEFINE_EVENT
    
    BUTTON_EVENT[dvTP,1]
    {
    	PUSH:
    	{		
    		LOCAL_VAR INTEGER i
    		
    		GET_URL_LIST(dvMASTER,UrlList,0) (* Get ALL URLs *)
    		FOR(i=1;i<=LENGTH_ARRAY(UrlList);i++)
    		{
    			SEND_STRING 0,"UrlList[i].URL"
    		}
    	}
    }
    
  • Joe HebertJoe Hebert Posts: 2,159
    Use the return value of GET_URL_LIST as the FOR loop count instead of using the length (I don?t think it gets set by the function.)
  • rdriederrdrieder Posts: 25
    Works, but with compile warnings...

    Changed code, tried SINTEGER and SLONG for the LOCAL_VAR cnt, and get compile warnings, but the code does work now. Any ideas?
    DEFINE_EVENT
    
    BUTTON_EVENT[dvTP,1]
    {
    	PUSH:
    	{		
    		LOCAL_VAR INTEGER i
    		LOCAL_VAR INTEGER cnt
    		
    		cnt = GET_URL_LIST(dvMASTER,UrlList,0) (* Get ALL URLs *)
    		FOR(i=1;i<=cnt;i++)
    		{
    		        SEND_STRING 0,"UrlList[i].URL"
    		}
    	}
    }
    
  • Joe HebertJoe Hebert Posts: 2,159
    Try this:
    BUTTON_EVENT[dvTP,1]
    {
        PUSH:
        {       
            LOCAL_VAR INTEGER i
            LOCAL_VAR SLONG ret
    	LOCAL_VAR INTEGER cnt
           
            ret = GET_URL_LIST(dvMASTER,UrlList,0) (* Get ALL URLs *)
    	IF (ret > 0) { //if function does not return an error (-1 or -2) and there are URLs in the list
    	   cnt = TYPE_CAST(ret) //thanks for the warning but we're ok
    	   FOR(i=1;i<=cnt;i++)
    	   {
    		   SEND_STRING 0,"UrlList[i].URL"
    	   }
    	 }
        }
    }
    

    You don?t need local_vars unless they?re declared that way for debugging purposes.
  • rdriederrdrieder Posts: 25
    Works with TYPE_CAST

    Thanks Joe, LOCAL_VARS were used just for debugging. Appreciate your help.
  • Joe HebertJoe Hebert Posts: 2,159
    Glad to help. Have fun.
Sign In or Register to comment.