Multi Commander > Script

Select / deselect switch fault?

<< < (4/5) > >>

Ulfhednar:
 ???
That was the only way I found to make the FindFiles function accept the path.
[$n] left the value $CurrentNameFullPath as 'unknown'.

Running this on the source dir seems to work 100%, the debug shows what I think it should (but I am  still a newb) so which component is introducing the loop?
$CurrentNameFullPath = $path[1]; ?
I thought I needed $n++ (like regex) to make sure the path was fully scanned.


--- Code: ---@var $root = GetSourcePath();
@var $path = PathGetParts( $root );
@var $items = arrayCount($path);
@var $CurrentNameFullPath;
@var $n = 0;

for( $n = 0; $n < $items; $n++ )

{
  $CurrentNameFullPath = $path[1];
  arrayRemove($path, 2);
  }


@var $arrFiles = FindFiles( $CurrentNameFullPath + "*.zip");
@var $count = arrayCount($arrFiles);
@var $zipFiles = "";
@var $zip;
@var $n1;


// Create ; separated list with all zip files to unpack
for( $n1 = 0; $n1 < $count ; $n1++ )
{
 $zip = $arrFiles[ $n1 ];
 $zipFiles += $zip;
 $zipFiles += ";";
}

MC.Filesystem.Unpack FILE="{$zipFiles}" TARGET="${sourcepath}"

--- End code ---

Thanks so much for fixing the debugger in the latest release 4.3 b1698, it has made my many critical  errors easier to handle!  :)

Mathias (Author):
It might work but you are doing crazy things that does not make sense.

The path you set at

--- Code: ---$CurrentNameFullPath = $path[1];
--- End code ---
is the same as you get from the start

--- Code: ---@var $root = GetSourcePath();
--- End code ---

Also the first "for" loop is messed up and is not running so not sure what you are doing with that..

Also for source path you are using the MultiTags that are for simple customcommands. but this is a MultiScript so even thought it works it is not very "good" code.
There is MultiScript functions for it that you already are using.

--- Code: ---@var $root = GetSourcePath();
--- End code ---
Just send $root to it.

Ulfhednar:
Ahh I see.
I had initially made a mistake with the

--- Code: ---@var $arrFiles = FindFiles( <Path> + "*.zip");
--- End code ---
line that led me to seek an array, which it then eventually accepted.

But if I had had that line correct my thought of GetSourcePath(); would have been accepted.  My syntax errors blocked that.
So one syntax error led to a flood of 'patches'  until it eventually worked.
Maybe I should apply for jobs in the PC game software industry, I've seen this kind of thing there more than once.  :P
I can see why it would make you mad....  it only needed to be -


--- Code: ---@var $root = GetSourcePath();
@var $arrFiles = FindFiles( $root + "*.zip");
@var $count = arrayCount($arrFiles);
@var $zipFiles = "";
@var $zip;
@var $n1;


// Create ; separated list with all zip files to unpack
for( $n1 = 0; $n1 < $count ; $n1++ )
{
 $zip = $arrFiles[ $n1 ];
 $zipFiles += $zip;
 $zipFiles += ";";
}

MC.Filesystem.Unpack FILE="{$zipFiles}" TARGET="${sourcepath}"
--- End code ---

The upside is I have learnt good some new things.  My redundant code did get me to experiment with functions I didn't follow before.

Mathias (Author):

--- Quote from: Ulfhednar on June 07, 2014, 00:00:11 ---I can see why it would make you mad....  it only needed to be -

--- End quote ---
Not mad, I was just confused and wonder if there was some reason behind it that I did not see.

Ulfhednar:
OK I didn't want you to feel you were wasting your time.  ;)

I did wonder why I had to define so many elements to get it to recognize & accept the path - took me back to Basic - but it started to do other things so it became a challenge/game to find more functions & get different results output to the debugger.

I can now start looking at making a more complex script with multiple tasks - my original ideas may yet be possible!   :o

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version