Hi there, I stumbled across this old thread and thought what a great idea it was!!! So I copied the code, cleaned up the SC changes and away it went - awesome!!! But I wanted to extend it and make it a bit more than it was. I wanted it to:
1. End when more than one file is selected.
2. End when a 'non-valid' filetype is selected.
3. Open inputfile dialog when nothing is selected (then it could be used for any file, anywhere, not just limited to the current folder).
So far I've got two lots of code that work independently but I'm having real trouble getting them to work together.
This one fulfills numbers 1&3:
Code: Select all
"QuickFileEdit-2-works"
//opens inputfile on no selection
//BUT works on any filetype
end(get("CountSelected") > 1), "Only one item may be selected.";
if (get("CountSelected") < 1) {
focus "l";
$file = inputfile("<curpath>", "txt|xys|ini", "Select file to Edit");
}
else {
$file = report("{Fullname}", 1);
}
$data = input("Quick File Edit: $file", ,readfile($file), w);
status writefile($file, $data);
And this one fulfills numbers 1&2:
Code: Select all
"QuickFileEdit-3-works"
//works on valid filetypes only
end(get("CountSelected") > 1), "Only one item may be selected.";
$file = report("{Fullname}", 1);
$ext = get("curitem", "ext");
if($ext==txt||$ext==xys||$ext==ini){
$data = input("Quick File Edit: $file", ,readfile($file), w);
status writefile($file, $data);
}
else {
msg "Invalid filetype selected.";
break;
}
I'm pretty sure I just need to include an elseif but I can't for the life of me figure out what order the pieces of code should go in.
I'm also sure there must be a better way than using if($ext==txt||$ext==xys||$ext==ini) to set the 'valid' file extensions but I couldn't figure out how to make a variable contain multiple values (or any other command I should use instead).
Thanks for any help.