VrS (Variant realities Script) — File Browser

VrSVariantrealitiesScriptv2.0 / VrSVariantrealitiesScriptv2.0 / VrS / System / Core / vmodule.mrc

vmodule.mrc — 19.45 KB — Download this file

;#[vHD@3.0 C!vModule@1.0.0;2001.11.1;Variant<variant@variantrealities.com>]
;#[SD ]
;#[Incl ]
;#[vModule is VrS' module management system. It handles installing, updating, and uninstalling modules.]
;#[ ]
;#[ ]

alias vUpdate {
  vGui.Window -td vUpdate 185 88 375 328 -xm Update VrS
}
alias vGui.vUpdate.Process {
  if ($1-2 == WINDOW Init) {
    hadd vGui vUpdate.Sections.Line1 Download updates
    hadd vGui vUpdate.Sections.Line2 Install packages
    hadd vGui vUpdate.Sections.Line3 Unload modules
    set %vGui.vUpdate.Sections.NumLines 3
    set %vGui.vUpdate.Sections.Selected 1
    set %vGui.vUpdate.List.Style Single
    vUpdate.BuildList
  }
  elseif ($1-2 == WINDOW DrawObjects) {
    vGui.Obj.Label.Draw - vUpdate Normal 23 35 50 15 NewObject4 Section:
    vUpdate.DrawObjects
    .timerUpdateList 1 0 vGui.vUpdate.Process Sections Selected
  }
  elseif ($1-2 == Close MouseClicked) { vGui.Close vUpdate }
  elseif ($1-2 == Sections Selected) {
    if (%vGui.vUpdate.Sections.Selected == 1) {
      httpget vrs.variantrealities.com/vrsupdate.php
      vUpdate.Text Connecting...
      vGui.Update vUpdate
      hdel -w vGui vUpdate.List.Line*
      unset %vGui.vUpdate.List.NumLines
      unset %vGui.vUpdate.List.Selected
      vUpdate.DrawObjects
    }
    else {
      vUpdate.BuildList
      vUpdate.DrawObjects
    }
  }
  elseif ($1-2 == List Selected) {
    vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 3 && %vGui.vUpdate.List.Selected,Normal,Disabled) 281 144 74 24 Unload 13 Unload
  }
  elseif ($1-2 == Download MouseClicked) {
    httpget vrs.variantrealities.com/updates/ $+ $hget(vGui,$+(vUpdate.List.Line,%vGui.vUpdate.List.Selected))
    vUpdate.Text Connecting...
    set %vGui.vUpdate.Downloading 1
    vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 1 && %vGui.vUpdate.List.Selected && !%vGui.vUpdate.Downloading,Normal,Disabled) 281 80 74 24 Download 13 Download
    unset %vGui.vGuiCORE.CurrentObj
    vGui.Update vUpdate
  }
  elseif ($1-2 == Delete MouseClicked) {
    .timerDeleteFile 1 0 DeleteFile
  }
  elseif ($1-2 == Install MouseClicked) {
    var %File = $hget(vGui,$+(vUpdate.List.Line,%vGui.vUpdate.List.Selected))
    if ($gettok(%File,-3-,46) == Update.vpk.gz) {
      vGui.Close vUpdate
      vConsole
      installupdate $+($mircdir $+ Temp\ $+ %File)
    }
    elseif ($gettok(%File,-3-,46) == Theme.vpk.gz) {
      vUpdate.Text Installing theme... | vGui.Update vUpdate
      .vPak -uzd $vrsdir($+(Temp\,%File)) $vrsdir($+(Themes\,$gettok(%File,1,46)))
      vUpdate.Text Installed | vGui.Update vUpdate
    }
    elseif ($gettok(%File,-3-,46) == Module.vpk.gz) {
      vUpdate.Text Installing module... | vGui.Update vUpdate
      .vPak -uzd $vrsdir($+(Temp\,%File)) $vrsdir($+(System\Modules\,$gettok(%File,1,46)))
      vUpdate.Text $vModule.Inst($vrsdir($+(System\Modules\,$gettok(%File,1,46),\,$gettok(%File,1,46),.,mrc)).noquotes) | vGui.Update vUpdate
    }
  }
}
alias -l DeleteFile {
  if ($isfile(Temp\ $+ $hget(vGui,$+(vUpdate.List.Line,%vGui.vUpdate.List.Selected)))) {
    .remove Temp\ $+ $hget(vGui,$+(vUpdate.List.Line,%vGui.vUpdate.List.Selected))
  }
  vUpdate.BuildList
  vGui.Obj.!Listbox.Draw - vUpdate Normal 23 80 250 184 List
  vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 2 && %vGui.vUpdate.List.Selected,Normal,Disabled) 281 112 74 24 Install 13 Install
  vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 2 && %vGui.vUpdate.List.Selected,Normal,Disabled) 281 240 74 24 Delete 13 Delete
  if (!%vGui.vUpdate.List.NumLines) { unset %vGui.vGuiCORE.CurrentObj }
  vGui.Update vUpdate
}
alias vGui.vUpdate.CheckObjects {
  if (%vGui.vUpdate.Sections.Selected == 1) && (%vGui.vUpdate.List.Selected) && (!%vGui.vUpdate.Downloading) { $(%vGui.vUpdate.Download.Location,2) }
  if (%vGui.vUpdate.Sections.Selected == 2) && (%vGui.vUpdate.List.Selected) { $(%vGui.vUpdate.Install.Location,2) }
  if (%vGui.vUpdate.Sections.Selected == 2) && (%vGui.vUpdate.List.Selected) { $(%vGui.vUpdate.Delete.Location,2) }
  if (%vGui.vUpdate.Sections.Selected == 3) && (%vGui.vUpdate.List.Selected) { $(%vGui.vUpdate.Unload.Location,2) }
  $(%vGui.vUpdate.Close.Location,2)
  $(%vGui.vUpdate.List.Location,2)
  $(%vGui.vUpdate.Sections.Location,2)
}


alias vUpdate.DrawObjects {
  vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 1 && %vGui.vUpdate.List.Selected && !%vGui.vUpdate.Downloading,Normal,Disabled) 281 80 74 24 Download 13 Download
  vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 2 && %vGui.vUpdate.List.Selected,Normal,Disabled) 281 112 74 24 Install 13 Install
  vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 2 && %vGui.vUpdate.List.Selected,Normal,Disabled) 281 240 74 24 Delete 13 Delete
  vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 3 && %vGui.vUpdate.List.Selected,Normal,Disabled) 281 144 74 24 Unload 13 Unload
  vGui.Obj.Button.Draw - vUpdate Normal 281 282 74 24 Close 13 Close
  vGui.Obj.!Combo.Draw - vUpdate Normal 23 51 250 110 Sections
  vGui.Obj.!Listbox.Draw - vUpdate Normal 23 80 250 184 List
}

alias vUpdate.BuildList {
  hdel -w vGui vUpdate.List.Line*
  unset %vGui.vUpdate.List.NumLines
  unset %vGui.vUpdate.List.Selected
  if (%vGui.vUpdate.Sections.Selected == 1) {
    var %Counter = 1, %Total = $lines(Temp\vrsupdate.php)
    while (%Counter <= %Total) {
      hadd vGui vUpdate.List.Line $+ %Counter $remove($read(Temp\vrsupdate.php,%Counter),<br>)
      inc %Counter
    }
    if (%Total) { set %vGui.vUpdate.List.Selected 1 }
    set %vGui.vUpdate.List.NumLines $calc(%Counter - 1)
    .remove Temp\vrsupdate.php
  }
  elseif (%vGui.vUpdate.Sections.Selected == 2) {
    var %Counter = 1, %Total = $findfile(Temp\,*.vpk.gz,0)
    while (%Counter <= %Total) {
      hadd vGui vUpdate.List.Line $+ %Counter $nopath($findfile(Temp\,*.vpk.gz,%Counter))
      inc %Counter
    }
    if (%Total) { set %vGui.vUpdate.List.Selected 1 }
    set %vGui.vUpdate.List.NumLines $calc(%Counter - 1)
  }
  elseif (%vGui.vUpdate.Sections.Selected == 3) {
    var %Counter = 1, %Total = $vModule.List(0)
    while (%Counter <= %Total) {
      var %Module = $vModule.List(%Counter)
      hadd vGui vUpdate.List.Line $+ %Counter $vHD.SName(%Module).Version $vHD.SName(%Module).Name 
      inc %Counter 
    }
    if (%Total) { set %vGui.vUpdate.List.Selected 1 }
    set %vGui.vUpdate.List.NumLines $calc(%Counter - 1)
  }
}

alias vUpdate.Text { vGui.Obj.Label.Draw - vUpdate Normal 23 269 250 17 NewObject5 $1- }
alias vUpdate.DownloadProgress {
  vGui.Obj.Progress.Draw - vUpdate Normal 23 286 250 20 Progress $2 $3 $4- - &percent% 
  vGui.Update vUpdate
}

on *:signal:vLib.HTTPFail: {
  if ($1 == vLib.ReceiveHTTP.vrs.variantrealities.com.80) {
    if ($window(@vGui.vUpdate)) {
      unset %vGui.vUpdate.Downloading
      vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 1 && %vGui.vUpdate.List.Selected && !%vGui.vUpdate.Downloading,Normal,Disabled) 281 80 74 24 Download 13 Download
      if ($2 != 404) { vUpdate.Text Unable to connect to server. }
      else { vUpdate.Text 404 - File not found. }
      vGui.Update vUpdate
    }
  }
}
on *:signal:vLib.HTTPRcvd: {
  if ($1 == vLib.ReceiveHTTP.vrs.variantrealities.com.80) {
    if ($4 == /vrsupdate.php) {
      ;Finished checking for updates
      if ($window(@vGui.vUpdate)) {
        vUpdate.Text Received update list from server.
        vUpdate.BuildList
        vUpdate.DrawObjects
        vGui.Update vUpdate
      }
      else {
        var %CurrentVer = $remove($read($+(",$mircdir,Temp\vrsupdate.php,"),w,*.Update.vpk.gz*),<br>)
        %CurrentVer = $gettok(%CurrentVer,$+(1-,$calc($numtok(%CurrentVer,46) - 3)),46)
        var %LocalVer = $+(VrS.v,$vrs(release),-,$vrs(version))
        if (%CurrentVer != %LocalVer) { iecho There is a new version of VrS available. Type /vUpdate to download it. }
      }
    }
    else {
      ;Download complete
      unset %vGui.vUpdate.Downloading
      vGui.Obj.Button.Draw - vUpdate $iif(%vGui.vUpdate.Sections.Selected == 1 && %vGui.vUpdate.List.Selected && !%vGui.vUpdate.Downloading,Normal,Disabled) 281 80 74 24 Download 13 Download
      vUpdate.Text File download complete. | vGui.Update vUpdate
    }
  }
  ;vecho $signal $1-
}

on *:signal:vLib.HTTPProgress: {
  if ($1 == vLib.ReceiveHTTP.vrs.variantrealities.com.80) {
    if ($window(@vGui.vUpdate)) {
      if ($3 == Unknown) { vUpdate.Text Downloading... | vGui.Update vUpdate }
      if ($3 != Unknown) {
        var %ElapsedTime = $calc($ticks - $gettok($sock($1).mark,4,32))
        vUpdate.Text Downloading: $vFT3.ToKB($calc($2 / (%ElapsedTime / 1000))) $+ /sec | vGui.Update vUpdate
        .timervUpdateProgress 1 0 vUpdate.DownloadProgress $1 $3 $2 $vFT3.ToKB($2) $+ / $+ $vFT3.ToKB($3)
      }
    }
  }
}

on *:signal:start.2: { checkupdate }

alias checkupdate {
  httpget vrs.variantrealities.com/vrsupdate.php
}

;Syntax: /installupdate <path-to-vpk-file>
alias installupdate {
  if (!$1-) {
    var %File = $sfile(VrS.*.Update.vpk.gz,Select the update file to use:,Update)
    if (%File) { tokenize 32 %File }
    else { return }
  }
  deltree $+($mircdir,Temp\Update\)
  vecho Decompressing...
  .vPak -uzd $+(",$1-,") $+(",$mircdir,Temp\Update\,")

  vecho Installing modules...
  ;Install modules
  var %i = 1, %t = $findfile($+(",$mircdir,Temp\Update\System\Modules\,"),*.mrc,0), %File
  while (%i <= %t) {
    %File = $findfile($+(",$mircdir,Temp\Update\System\Modules\,"),*.mrc,%i)
    if ($+(Modules\,$noext($nopath(%File))) == $gettok($nofile(%File),-2-3,92)) {
      ;vecho Installing module: %File
      ;Main module file, install
      echo -a $vModule.Inst(%File).Ignore
    }
    inc %i
  }

  vecho Installing new documentation...
  ;Install documentation
  var %i = 1, %t = $findfile($+(",$mircdir,Temp\Update\Docs\,"),*,0), %File
  while (%i <= %t) {
    %File = $findfile($+(",$mircdir,Temp\Update\Docs\,"),*,%i)
    var %Dir = $+($mircdir,Docs\,$nofile($remove(%File,$+($mircdir,Temp\Update\Docs\))))
    if (!$isdir(%Dir)) { mkpath %Dir }
    .copy -o $+(",%File,") $+(",$mircdir,Docs\,$remove(%File,$+($mircdir,Temp\Update\Docs\)),")
    inc %i
  }
  var %i = 1, %t = $dll(0)
  while (%i <= %t) { dll -u $+(",$dll(%i),") | inc %i }
  vecho Installing core files...
  ;Install core files
  var %i = 1, %t = $findfile($+(",$mircdir,Temp\Update\System\Core\,"),*,0), %File
  while (%i <= %t) {
    %File = $findfile($+(",$mircdir,Temp\Update\System\Core\,"),*,%i)
    var %Dir = $+($mircdir,System\Core\,$nofile($remove(%File,$+($mircdir,Temp\Update\System\Core\))))
    if (!$isdir(%Dir)) { mkpath %Dir }
    if ($right(%File,4) == .dll) && ($isfile($+(",$mircdir,System\Core\,$remove(%File,$+($mircdir,Temp\Update\System\Core\)),"))) { dll -u $+(",$mircdir,System\Core\,$remove(%File,$+($mircdir,Temp\Update\System\Core\)),") }
    .remove $+(",$mircdir,System\Core\,$remove(%File,$+($mircdir,Temp\Update\System\Core\)),")
    .copy -o $+(",%File,") $+(",$mircdir,System\Core\,$remove(%File,$+($mircdir,Temp\Update\System\Core\)),")
    if ($right(%File,4) == .mrc) { 
      if ($remove(%File,$+($mircdir,Temp\Update\System\Core\)) != aliases.mrc) { .timer 1 0 .reload -rs $+(",$mircdir,System\Core\,$remove(%File,$+($mircdir,Temp\Update\System\Core\)),") }
      else { .timer 1 0 .load -a $+(",$mircdir,System\Core\,$remove(%File,$+($mircdir,Temp\Update\System\Core\)),") }
    }
    inc %i
  }

  deltree $+($mircdir,Temp\Update\)
  vecho Restarting mIRC to complete the update...
  .timer 1 1 restartmirc
}

alias restartmirc {
  saveini
  run $nopath($mircexe)
  exit
}

alias vModule.vPak {
  if (!$1-) {
    var %ModuleDir = $sdir(System\Modules\,Select the module to vPak:,Compress)
    if (%ModuleDir) { tokenize 32 %ModuleDir }
    else { return }
  }
  tokenize 32 $gettok($1-,-1,92)
  var %Version = $vHD.SInfo($+($mircdir\System\Modules\,$1,\,$1,.mrc)).Version
  var %Name = $vHD.SInfo($+($mircdir\System\Modules\,$1,\,$1,.mrc)).Name
  vPak -pzd $+(",$mircdir,Temp\,%Name,.,%Version,.Module.vpk,") $vrsdir($+(System\Modules\,$1-))
}

alias vModule.Load { 
  if (!$1-) {
    var %File = $sfile(*.mrc,Select the module to load:,Load)
    if (%File) { tokenize 32 %File }
    else { return }
  }
  else { tokenize 32 $+($mircdir,System\Modules\,$1,\,$1,.mrc) }
  echo -a $vModule.Inst($1-)
}
alias vModule.Unload { echo -a $vModule.Uninst($script($+($1,.mrc))) }

;Syntax: $vModule.Inst(<Full module filename>)
;Use the .Ignore property if you wish for vModule to ignore dependancies when
;installing. Useful for installing full updates so you don't have to worry
;about version dependancies while installing.
alias vModule.Inst {
  ;Check header
  if (!$vHD.HasHeader($1)) { return vModule Error: Invalid or no header found }
  ;Check dependancies to make sure they check out
  var %Counter = 1, %Total = $vHD.Dep($1,0), %Module, %RequiredModules
  while (%Counter <= %Total) {
    %Module = $vHD.Dep($1,%Counter)
    if ($vModule.Check(%Module).Ver != OK) { %RequiredModules = %RequiredModules %Module }
    inc %Counter
  }
  if (%RequiredModules) && ($prop != Ignore) { return vModule Error: Required module(s) not found: %RequiredModules }
  ;Copy file(s) to proper location, as well as
  ;load the file, and load all includes
  var %ModuleDir = $+($mircdir,System\Modules\,$vHD.SInfo($1).Name,\)
  var %Counter = 1, %Total = $vHD.Dep($1,0,Includes), %Module
  mkpath %ModuleDir
  if ($nofile($1) != %ModuleDir) { .copy -o $+(",$1,") $+(",%ModuleDir,") }
  .load -rs $+(",%ModuleDir,$nopath($1),")
  RemFromvReg $vHD.SInfo($+(%ModuleDir,$nopath($1))).SName
  AddTovReg $vHD.SInfo($+(%ModuleDir,$nopath($1))).SName
  while (%Counter <= %Total) {
    %Module = $vHD.Dep($1,%Counter,Includes).Name
    if ($nofile($1) != %ModuleDir) { .copy -o $+(",$nofile($1),%Module,.mrc,") $+(",%ModuleDir,") }
    .load -rs $+(",%ModuleDir,%Module,.mrc,")
    inc %Counter
  }
  ;Load file, load all includes
  ;Run Install alias (if found in module)
  set -u %vModule.FromDir $nofile($1)
  set -u %vModule.ToDir %ModuleDir
  if ($vHD.SInfo($+(%ModuleDir,$nopath($1))).Install) { $ifmatch }
  Return vModule: Loaded module: $vHD.SInfo($+(%ModuleDir,$nopath($1))).Name
}

;Syntax: $vModule.UnInst(<Full module filename>)
alias vModule.UnInst {
  ;Check header
  if (!$vHD.HasHeader($1)) { return vModule Error: Invalid or no header found }
  ;Check dependancies to make sure nothing is dependant on this module
  var %Counter = 1, %Total = $numtok($vReg(G,vModule,ModuleList),32), %Module, %DependantModules
  var %Name = $vHD.SInfo($1).Name
  while (%Counter <= %Total) {
    %Module = $vHD.SName($gettok($vReg(G,vModule,ModuleList),%Counter,32))
    var %Counter2 = 1, %Total2 = $vHD.Dep($script($+(%Module,.mrc)),0), %List = $vHD.Dep($script($+(%Module,.mrc)),List)
    while (%Counter2 <= %Total2) {
      if ($vHD.SName($gettok(%List,%Counter2,59)).Name == %Name) { %DependantModules = %DependantModules %Module }
      inc %Counter2
    }
    inc %Counter
  }
  if (%DependantModules) { return vModule Error: Can't uninstall module - other module(s) depend on it: %DependantModules }
  ;Unload and delete module files

  ;Run Uninstall alias (if found in module)
  set -u %vModule.FromDir $nofile($1)
  if ($vHD.SInfo($1).Uninstall) { $ifmatch }

  var %ModuleDir = $+($mircdir,System\Modules\,$vHD.SInfo($1).Name,\)
  var %Counter = 1, %Total = $vHD.Dep($1,0,Includes), %Module
  RemFromvReg $vHD.SInfo($+(%ModuleDir,$nopath($1))).SName
  while (%Counter <= %Total) {
    %Module = $vHD.Dep($1,%Counter,Includes).Name
    .unload -rs $+(",%ModuleDir,%Module,.mrc,")
    ;.remove $+(",%ModuleDir,%Module,.mrc,")
    inc %Counter
  }
  .unload -rs $+(",%ModuleDir,$nopath($1),")
  ;.remove $+(",%ModuleDir,$nopath($1),")
  ;deltree %ModuleDir
  Return vModule: Unloaded module: %Name
}

;Syntax: /AddTovReg <C!scriptname@1.0.0>
alias -l AddTovReg {
  var %NewLine = $addtok($vReg(G,vModule,ModuleList),$1,32)
  vReg G vModule ModuleList %NewLine
  vReg G vModule $vHD.SName($1).Name $vHD.SName($1).Version $remove($script($+($vHD.SName($1).Name,.mrc)),$mircdir)
}

;Syntax: /RemFromvReg <C!scriptname@1.0.0>
alias -l RemFromvReg {
  var %NewLine = $remtok($vReg(G,vModule,ModuleList),$1,1,32)
  vReg G vModule ModuleList %NewLine
  vReg G vModule $vHD.SName($1).Name
}

;Syntax: $vModule.Check(<C!scriptname@1.0.0>)
;Properties: Ver Loaded
alias vModule.Check { 
  if ($prop == Ver) { 
    if ($vReg(G,vModule,$vHD.SName($1))) && ($gettok($vReg(G,vModule,$vHD.SName($1)),1,32) >= $vHD.SName($1).Version) { return OK }
    else { return $gettok($vReg(G,vModule,$vHD.SName($1)),1,32) }
  }
  elseif ($prop == Loaded) {
    if ($vHD.HasHeader($script($+($vHD.SName($1),.mrc))) { return OK }
    else { return NotLoaded }
  }
}
alias vModule.List {
  if ($1 == 0) { return $numtok($vReg(G,vModule,ModuleList),32) }
  elseif ($1 isnum) { return $gettok($vReg(G,vModule,ModuleList),$1,32) }
}

;----------vHD header functions----------
;This function checks to make sure the specified script file is a valid VrS2+ script.
;Returns $true or $false.
; Syntax: $vHD.HasHeader(<full script filename>)
alias vHD.HasHeader {
  var %File = $+(",$1-,"), %Line = $read(%File,n,1), %vHD = ;#[vHD@3.0
  if ($left(%Line,$len(%vHD)) == %vHD) { return $true }
  else { return $false }
}

; Syntax: $vHD.SInfo(<full script filename>)
;Properties: Name, Version, Type, Date, Author, Email, Info, Install, UnInstall
alias vHD.SInfo {
  if ($vHD.HasHeader($1-) == $false) { return }
  var %File = $+(",$1-,") ,%Line = $read(%File,n,1)
  if ($prop == Name) { return $vHD.SName($gettok($gettok(%Line,2-,32),1,59)).Name }
  elseif ($prop == SName) { return $gettok($gettok(%Line,2-,32),1,59) }
  elseif ($prop == Version) { return $vHD.SName($gettok($gettok(%Line,2-,32),1,59)).Version }
  elseif ($prop == Type) { return $vHD.SName($gettok($gettok(%Line,2-,32),1,59)).Type }
  elseif ($prop == Date) { return $gettok($gettok(%Line,2-,32),2,59) }
  elseif ($prop == Author) { return $gettok($gettok($gettok(%Line,2-,32),3,59),1,60) }
  elseif ($prop == Email) { return $gettok($gettok($gettok($gettok(%Line,2-,32),3,59),2,60),1,62) }
  elseif ($prop == Info) { return $right($left($read(%File,n,4),-1),-3) }
  elseif ($prop == Install) { return $right($left($read(%File,n,5),-1),-3) }
  elseif ($prop == UnInstall) { return $right($left($read(%File,n,6),-1),-3) }
}

; Syntax: $vHD.Files(<Full script filename>,<N>,[Includes])
;Lists dependancies by default, but if Includes is specified, then this function
;lists all files the module includes.
;Properties: Name, Version, Type
alias vHD.Dep {
  if ($vHD.HasHeader($1) == $false) { return }
  var %File = $+(",$1,") ,%Line = $read(%File,n,$iif($3 == Includes,3,2))
  %Line = $left($gettok(%Line,2-,32),-1)
  if ($2 == List) { return %Line }
  elseif ($2 == 0) { return $iif(%Line != $null,$numtok(%Line,59),0) }
  else { return $iif($prop,$vHD.SName($gettok(%Line,$2,59)) [ $+ . $+ [ $prop ] ] ,$gettok(%Line,$2,59)) }
}

; Syntax: $vHD.SName(<C!scriptname@1.0.0>)
alias vHD.SName {
  if ($prop == Name) || ($prop == $null) { return $gettok($gettok($1,1,64),2,33) }
  elseif ($prop == Type) { return $gettok($1,1,33) }
  elseif ($prop == Version) { return $gettok($gettok($1,2,64),1,36) }
}
alias vModule.LoadAll {
  var %i 1
  while ($vModule.List(%i)) {
    vmodule.load $gettok($gettok($vModule.List(%i),2,33),1,64)
    inc %i
  }
}