So I've done a lot of thinking and coding...
-----

Quote:
You should be careful with this, loading a full directory or even just all files matching a simple wildcard like remote*.ini in a directory is potentially dangerous, if a malicious user can get a file matching in that directory you would load that file.


This is true. The script before this post was completely blind. It loaded all remotes without a safeguard.
-----
Quote:
What you were doing originally is much safer, and you can easily reduce the size of the code.


Safe? Yes. Easy? Kinda. Fun? No. Also, it wasn't the size of the code that was daunting. I was put off by the copy/pasting.
-----
Quote:
I'd recommend to avoid the $findfile loop and just loop over your list of known files like you had first:
Code:
var %files remote1.ini remote2.ini remoteN.ini,%a 1
while ($gettok(%files,%a,32) != $null) {
.reload -rs $qt(path\to\ $+ $v1)
inc %a
}

just add script files to %files, space seperated

This sounds simple, but it's basically a re-skin of my old code. It would nearly be easier to keep copy/pasting like I was before, because anytime I rename a file, I have to change it manually in the main remote.
-----

So, here is what I think to be the easiest "safe" code possible to a novice scripter such as myself.
In short, it loads all files in your C:User\Filepath\Roaming\mIRC\Scripts folder and counts them on the first pass. You'll want to manually check to make sure there's nothing dangerous in those folders.
On successive Unloads/Loads, it compares the number of old files to the number of new files.(I plan to figure out a way to make it remember file names and update here with what I come up with.)
If there is a discrepency between the old files and the new files, it will bring up a dialog to decide what you want to do.
I'm off to work right now, but I'll be back in a few hours to read your input.
Code:
;Script loader
alias scripts_dialog {
  dialog -m scripts_dialog scripts_dialog
}
;Warning dialog
alias unknown_script {
  echo -a $dialog(unknown_script,unknown_script)
}

;Script-loading dialog
dialog scripts_dialog {
  title "Scripts"
  size -1 -1 80 26
  option dbu
  button "Load", 1, 2 2 37 12
  button "Unload", 2, 41 2 37 12
  text "Scripts <placeholder>", 3, 2 16 76 8, center
}
;Buttons to load/unload all remote.*.ini files
on *:dialog:scripts_dialog:sclick:1-2:{
  set %scriptsCountNew $findfile(scripts,remote.*.ini,0,echo $1-)
  ;If a new file is found or an old file is missing
  if (%scriptsCountNew != %scriptsCountOld) {
    echo -a FOUND SCRIPT DISCREPENCY
    set %continue $dialog(unknown_script,unknown_script)
    echo -a Decided to %continue
    ;complete break in sequence at operator discretion
    if (%continue == Cancel) {
      echo -a Aborting script loader.
      halt
    }
  }
  noop $findfile(scripts,remote.*.ini,0,timerload1 1 $findfilen did -a scripts_dialog 3 Scripts $did($dname,$did) $+ ed.)
  echo -a Found %scriptsCountNew scripts.
  echo -a Attempting to $did($dname, $did).text scripts. . .
  noop $findfile(scripts,remote.*.ini,0,.timer 1 $findfilen $did($dname, $did).text -rs $+ $calc(5 + $findfilen) $1-)
  noop $findfile(scripts,remote.*.ini,0,.timer_notice 1 $findfilen echo -a Scripts $did($dname, $did).text $+ ed! )
  did -a scripts_dialog 3 Scripts $did($dname, $did).text $+ ing. . .
  set %scriptsCountOld %scriptsCountNew
}

;Dialog for unknown scripts
dialog unknown_script {
  title "Warning! Unexpected Scripts!"
  size -1 -1 275 98
  option dbu
  list 1, 2 2 271 80, radio
  button "Delete Selected", 2, 2 84 67 12
  radio "Continue", 3, 71 85 67 10
  radio "Cancel", 4, 140 85 67 10
  button "Go", 5, 209 84 64 12, ok
  edit "",6, 1 1 1 1, result hide
}

;populate list with found remote.*.ini files
on *:dialog:unknown_script:init:0: { did -c $dname 4 | did -o $dname 6 1 Cancel | noop $findfile(scripts,remote.*.ini,0,did -a unknown_script 1 $remove($1-,%System..filepath)) }
;Click a radio on the list and click "Delete Selected" to send it to Recycle Bin
on *:DIALOG:unknown_script:sclick:2:{ remove -b %System..filepath $+ $did($dname, 1).seltext | did -r $dname 1 | noop $findfile(scripts,remote.*.ini,0,did -a unknown_script 1 $remove($1-,%System..filepath)) }
;set hidden result, the edit box, to Continue/Cancel
on *:DIALOG:unknown_script:sclick:3:{ did -o $dname 6 1 Continue }
on *:DIALOG:unknown_script:sclick:4:{ did -o $dname 6 1 Cancel }

PS- The Variable "%System..filepath" is the same as "C:\file\path\" leading up to, but not including, mIRC's folder.

Last edited by KubosKube; 08/05/17 07:31 PM.