Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - multitek

Pages: [1]
1
Thanks for the clarification Mathias :)

2
Oh man you are a gem, the script works great (both variants). I really appreciate it, thanks a lot :)


Now let me see if I correctly understand how the code works, to get a better grasp on scripting that I just started looking at yesterday...

@var $dir = GetSourcePath();
// assign source path to the dir variable

@var $sel = GetSourceSelectedFileNames();
// assign selected filenames to the sel variable. since sel is not explicitly declared as an array, does this mean a variable automatically becomes an array by assigning to it multiple values (ie filenames)?

@var $sel = StrLines2Array( GetClipboardText() );
// assign filenames on the clipboard to the sel variable. internal function StrLines2Array converts mutiple lines of string into an array

@var $c = arrayCount( $sel );
// assign the number of elements in the array sel to the c variable

@var $n;
@var $f;
// declare variables, n for the following loop counter, f for filenames

for( $n = 0; $n < $c; $n++ )
// setting up the loop to go through all the elements in the array. start with n at zero, execute the loop and increase n by 1 for as long as n is smaller than c, ie the number of elements in the array

{
  $f = $dir ^ "\\" ^ PathGetNamePart( $sel[ $n ], 1 );
//this gets the filename part from the current array element and assigns it to the variable f, but I'm confused about the syntax. Specifically the "$dir ^ "\\" ^ " part. I'm pretty sure I would have made the mistake here of simply writing "$f = PathGetNamePart( $sel[ $n ], 1 );" Ah wait (sorry for writing as I think ;) ), we need the full length path name for the file we are about to create, not just its filename, so the part I'm asking about is prepending the filename with the full path, correct? Ok, just found ^ in the documentation so I think I was right there. But looking at the documentation example, why wouldn't "$f = $dir ^ PathGetNamePart( $sel[ $n ], 1 );" work? Or would it?

  if( FileExists( $f ) == 0 )
//check if a file already exists so that we don't overwrite it with the file we're about to create.
  {
    SaveStringToFile( $f, "" );
//finally create the file with the filename we stored in variable f
  }
}

Again let me thank you for your help, hope you don't mind me commenting the code :)

3
Hello,

I'm trying to create a button/hotkey that would create a new empty textfile (without extension) in source and name it ideally using the filename (also without extension) of the file currently selected in source, or if that's not possible from clipboard.

Example with name from selected in source:
In source I select a file named: NiceName.whatever (the extension is irrelevant, could be anything)
Running the script does the following:
1. takes NiceName from the selected file
2. creates a new empty text file in source
3. names it NiceName (the filename doesn't have any extension at all)

The clipboard variant:
I copy the name I want to the clipboard, for example ClipboardName
Running the script does the following:
1. creates a new empty text file in source
2. names it ClipboardName (again no extension, what's on the clipboard is the full name)


optional bonus: doing this on multiple files at once. So I select multiple files and the script performs the described procedure on all of them.

I've been going through the documentation for a while now, but sadly haven't found a way to create such a script, so your help is much appreciated.

Pages: [1]