Hi all!
I am trying to do a script who can do two diferent things depending if something is selected or not.
I am looking a command like the “object exists,” let’s say…
if( something is selected ) {
// do this
} else {
// do this instead
}
I think it could be something like this but is not working
if ( `ls -sl True` ) {
print "something selected";
}
else {
print "nothing selected";
}
I hope some guru of mel can help me with this, I coudn’t find anything on the web
Replies
string $sel[] = `ls -sl`;<br>if ($sel[0] == "") <br> {<br> print "Nothing"; <br> }<br>else<br> {<br> print $sel; <br> }//checks if object is selected<br>string $selt[] = `ls`;<br>for ($node in $selt) {<br> if (size(`ls -sl $node`)) {<br> //node is seleted<br> print($node + "\n"); <br> }<br>}Here is another one I got that I think is more simple and I like avoiding variables for this:
`ls -sl`)){
print "yes";
}
else{
print "no";
}
{<br> if (size (`ls -sl`) > 0){<br> print "yes";<br> }<br> <br> else{<br> print "no";<br> }<br>}