Simple yet useful scripts

Thought I’d start a thread of for small but useful little scripts where the emphasis is on the idea rather than the implementation. Kind of sparked from a small code block I did last week which is proving really useful. I was doing some debugging and getting fed up with going…

whatIs

then scanning for the path. So this little proc does the whatIs then wraps it in a system open for either the script itself, or it’s directory:

global proc whatIsOpen(string $MelProc , int $fileOrDir)
{
 	$Proc= ("whatIs " + "\"" + $MelProc + "\"");
	 $TestPath = `eval $Proc`; 
	 
	 string $script= substitute( "Mel procedure found in: ", (string)$TestPath, "");
	 string $filepart = (string)`match "[^/\\]*$" $script`; 
 	 string $mainDir = `substitute $filepart $script""`;
 	 
 	 if($fileOrDir == 0)
 	 {
	 	//system("load " + $mainDir );
	 	system ("explorer /select, \"" + `toNativePath($script)` +"\"");
	 }
 	 else
	 	system("load " + $script);
}

It’s often these little gems that save more time than anything else

Mark

cool, good idea.

btw, if you want to add functionality to that to make it work in linux or osx, you can add the os check, and for the system line you would use…

mac:
system ("open …

linux (kde):
system ("kfmclient exec …

not really sure that there is a standard ‘open’ command that works across all linux desktops (gnome, kde, etc), but we’re only using kde here so thats what i’ve used.