File Select

By sinnercreed on May 28, 2007

This snippet is for returning a file selected by a user. Basically it checks that the text file "C:\Program Files\mIRC\filename.txt" exists and in the event that it doesn't it will create the file. The select file dialog is then displayed and allows the user to select a file, the name of the file selected is written to the created text file and then is returned as a value.

Usage: /select
Example: //echo -a $select

alias select {
  if ($isfile(C:Program FilesmIRCfilename.txt) == $false) {
    var %%% = aline @@@
    window -h @@@
    %%% strComputer="." 
    %%% Set objFSO = CreateObject("Scripting.FileSystemObject") 
    %%% Set objFile = objFSO.CreateTextFile("C:Program FilesmIRCfilename.txt") 
    savebuf @@@ file.vbs 
    window -c @@@ 
    .comopen creation wscript.shell 
    .comclose creation $com(creation,run,3,bstr,wscript file.vbs,uint,5,bool,true) 
    .remove file.vbs 
  }
  var %% = aline @@
  window -h @@
  %% Dim Name
  %% Set objectFile = CreateObject("UserAccounts.CommonDialog")
  %% objectFile.Filter = "All Files|*.*"
  %% objectFile.InitialDir = "C:"
  %% intResult = objectFile.ShowOpen
  %% Name = objectFile.FileName
  %% Set objFSO = CreateObject("Scripting.FileSystemObject")
  %% Set objFile = objFSO.OpenTextFile("C:Program FilesmIRCFilename.txt", 2, 1)
  %% objFile.Write("Name " & Name & " ")
  %% objFile.Close
  %% Wscript.Quit
  savebuf @@ select.vbs
  window -c @@
  .comopen selection wscript.shell
  .comclose selection $com(selection,run,3,bstr,wscript select.vbs,uint,5,bool,true)
  .remove select.vbs
  var %selected = $read(C:Program FilesmIRCFilename.txt, s, Name )
  return %selected
}  

Comments

Sign in to comment.
slub77   -  Mar 21, 2010

lol im'e making a directory dialog script, even though it has one, so yea woop woop to creativity, like you said

[quote]"What if mIRC didn't have that function?"[/quote

 Respond  
sinnercreed   -  May 30, 2007

Thanks, and yeah I knew it existed. My mindset when I script is usually \"What if mIRC didn\'t have that function?\" Just drives me to figure things out I suppose.

 Respond  
xDaeMoN   -  May 29, 2007

Not bad. mIRC also has this built-in.

/help $sfile

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.