Multi Commander > Script

Select / deselect switch fault?

<< < (3/5) > >>

Mathias (Author):
No you are mixing up stuff

FindFiles(...) are a MultiScript function..

CustomCommand Script is one line script. And they do not support variables and expression or other programing stuff.
MultiScript does support all that. BUT MultiScript can also call CustomCommand commands. But they are run by the CustomCommand engine.
So if you want to include a parameter that you use in a MultiScript on a line that is a CustomCommand. Then the Engine must first preprocces the parameter. and to be able to do that it must be encapselated inside a { }, 

Example
@var $file = GetMyFile();
MC.FileSystem.UnPack FILE="{$file}"

Everything inside the { } on the CustomCommand line is preprocces by the MultiScript engine
and the result of it is the inserted in that place before the CustomCommand is called.

In normal MultiScript functions you should not use { } around variable
They are used to define scope.. like the BEGIN , END of blocks for loops and expressions like IF, WHILE, FOR

Ulfhednar:
OK I see that I am confusing things....  I am gradually getting the topology now though, thanks.

I wasn't sure how to use the path variable, I tried with & without various {}, //, /, ", & nothing seemed to work when it came to giving the path to the command.
I am thinking I must need to process more @var, I can get the path shown but not correctly passed to the FindFiles.
All the array functions seem to include a file selection, & a plain string is rejected.

So I must need to define something else so that the $CurrentNameFullPath is able to be used.....  Few hours in I don't see it.


--- 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[ $n ];
  }


@var $arrFiles = FindFiles( $CurrentNameFullPath *.zip"); 
--- End code ---
Crashes here - Script engine error => Failed to process token - "$CurrentNameFullPath"

 --- can I restrict $path to the parts before the <blank> item $array [2]?  I unsuccessfully tried to trim element 2 with

--- Code: ---{
arrayRemove($path, 2);
}
--- End code ---

So I'm still missing something.  I will keep trying....

Mathias (Author):

--- Quote ---@var $arrFiles = FindFiles( $CurrentNameFullPath *.zip");   
--- End quote ---
You are missing a quotes and also you need to append the "*.zip" with the variable. for strings that is done with "+"


--- Code: ---@var $arrFiles = FindFiles( $CurrentNameFullPath + "*.zip");
--- End code ---


--- Quote ---arrayRemove($path, 2);
--- End quote ---
Works for me.. $path is an array (list) with 3 items. and arrayRemove( ..., 2 ) will remove the last one.

Ulfhednar:
 :)
My code deployment & running low on caffeine obviously getting in the way!
I have managed to finally get the path into the query  ;)


--- 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="{$folder}"

--- End code ---

But I have hit a curious snag.  See attached. 
Line 27 hangs the debugger & I must force MC to shut-down.  :o


--- Code: ---Description:
  A problem caused this program to stop interacting with Windows.

Problem signature:
  Problem Event Name: AppHangB1
  Application Name: MultiCommander.exe
  Application Version: 4.3.0.1694
  Application Timestamp: 538b2aaf
  Hang Signature: b3ef
  Hang Type: 0
  OS Version: 6.1.7601.2.1.0.256.1
  Locale ID: 2057
  Additional Hang Signature 1: b3ef002d84fb7e8c44004ed0fea8ce18
  Additional Hang Signature 2: bee0
  Additional Hang Signature 3: bee08592e35171afe9c215ff30dafcb5
  Additional Hang Signature 4: b3ef
  Additional Hang Signature 5: b3ef002d84fb7e8c44004ed0fea8ce18
  Additional Hang Signature 6: bee0
  Additional Hang Signature 7: bee08592e35171afe9c215ff30dafcb5
--- End code ---

Now I have to do some ''real'' work  :( 
I will come back to this later & look for the reason tho...
Thanks Mathias.

Mathias (Author):
I don't know why it crash I have not had time to test it

But ...

--- Quote from: Ulfhednar on June 06, 2014, 12:08:32 ---
--- Code: ---for( $n = 0; $n < $items; $n++ )
{
  $CurrentNameFullPath = $path[1];
  arrayRemove($path, 2);
 }

--- End code ---

--- End quote ---
Why are you doing this ? You are looping around the number of times there are items the $path list. but on every loop you do the same thing to same items in the list.
And you remove item from the $path list but you never use the path list again.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version