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
Show the 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" } } }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" } } }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.
Thanks Joe, LOCAL_VARS were used just for debugging. Appreciate your help.