Get URL segments for Joel's Internet plugin: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
m (Added category links.)
Line 60: Line 60:


-Stu
-Stu
[[{{ns:14}}:Internet Functions]]

Revision as of 22:10, 30 April 2005

Author: Afrow UK (talk, contrib)


Description

This function will slice up a URL for use with Joel's Internet.dll plugin.

Usage

Push "http://hmd.hostileintent.org/database/mapupdater.txt"
 Call ParseURL
Pop $R1
Pop $R0
 
# $R1 = database/mapupdater.txt
# $R0 = hmd.hostileintent.org
 
Internet::GetUrlCode $R0 $R1 $0
DetailPrint $0 # print URL code

The Function

Function ParseURL
 Exch $R0 ; url
 Push $R1
 Push $R2
 Push $R3
 
 StrCpy $R2 0
 Loop1:
  IntOp $R2 $R2 + 1
  StrCpy $R1 $R0 1 $R2
  StrCmp $R1 "" Done
  StrCmp $R1 "/" 0 Loop1
   IntOp $R2 $R2 + 2
   StrLen $R1 $R0
   IntOp $R2 $R1 - $R2
   StrCpy $R0 $R0 "" -$R2
 StrCpy $R2 0
 Loop2:
  IntOp $R2 $R2 + 1
  StrCpy $R1 $R0 1 $R2
  StrCmp $R1 "" Done
  StrCmp $R1 "/" 0 Loop2
   StrCpy $R1 $R0 $R2
   IntOp $R2 $R2 + 1
   StrLen $R3 $R0
   IntOp $R2 $R3 - $R2
   StrCpy $R0 $R0 "" -$R2
 Done:
 
 Pop $R3
 Pop $R2
 Exch $R1 ; address
 Exch
 Exch $R0 ; rest
FunctionEnd

-Stu