Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1

//Sets Application Name Based On What The Executable Is Called
ExtractFileName>Command_Line,strFileName
ExtractFileExt>Command_Line,strExt
StringReplace>%strFileName%,",,strFileName
StringReplace>%strExt%,",,strExt
StringReplace>%strFileName%,%strExt%,,strFileName
Trim>%strFileName%,strFileName
Let>APP_TITLE=%strFileName%
Let>WLN_NOCRLF=1

//Starts Main Checking Part Of Script Checking Every 90 Seconds
Label>Start
GoSub>sCheckInternetIP
If>%vHTML%=404 Error connecting to host
  Wait>15
  Goto>Start
EndIf
GoSub>sWriteIP
Wait>90
Goto>Start

//Checks My Current Internet IP Address By Querying My Router
SRT>sCheckInternetIP
  Label>lCheckInternetIP
  Let>HTTP_TIMEOUT=10
  Let>HTTP_REDIRECTS=1
  HTTPRequest>http://192.168.1.1/bsc_sta.htm,,GET,,vHTML,,,,
  Let>pattern=[IPAddress]
  RegEx>pattern,vHTML,1,matches,num,0
  If>num=1
    Let>vHTML=%matches_1%
  Else
    Wait>5
    GoTo>lCheckInternetIP
  EndIf
END>sCheckInternetIP

//Checks Existing IP Address Stored In Variable, If Blank It Creates One.
//If The Stored IP And The IP From The Router Match It Does Nothing.
//If The Stored IP And The Current IP From The Router Do Not Match, 
//It Updates DTDNS, Updates Variable & Notifies Me Via NotifyMyAndroid.
SRT>sWriteIP
  Let>REG_INTASSTR=1
    If>vRegIP={"vRegIP"}
    Let>vRegIP=%vHTML%
  EndIF
  If>%vHTML%=%vRegIP%
  Else
    HTTPRequest>http://www.dtdns.com/api/autodns.cfm?id=mjallen.gotgeeks.com&pw=XXXXXX&ip=%vHTML%&client=mjallen,,POST,,vPostResults,,,,
    Let>vRegIP=%vHTML%
    GoSub>sNotifyMyAndroid
  EndIf
END>sWriteIP

//Send To NotifyMyAndroid To Push A Message To My Phone About Update.
SRT>sNotifyMyAndroid
  Let>POSTDATA=apikey=XXXXXX&application=%strFileName%&event=Hostname Updated&description=%vPostResults%
  StringReplace>%POSTDATA%,%SPACE%,%20,POSTDATA
  HTTPRequest>http://www.notifymyandroid.com/publicapi/notify?,,POST,%POSTDATA%,vHTMLResult,,,,
END>sNotifyMyAndroid