Multi Commander > Script

Search routine

<< < (5/8) > >>

Ulfhednar:
I'm OK for regex's (not expert but OK) I like sites like this
http://regexlib.com/
for some ideas.
Regex is just something for me to attempt as I know I could use MC scripts with regex. 

I have been browsing your online docs.  Cannot see anything which says outright what a perfect base script looks like.  Trying to step through the script Jungle made, I can (more or less) see why it does what it does but cannot extrapolate that yet as it has a lot of operations & variables for my untrained eye.

I'm wondering about vars & 'scope' (sorry, I wasn't using correct terminology)
As you can see from the screen shot in the post above, the debugger didn't red-flag anything but it didn't rename the selected folder either. 
It shows the result but doesn't execute the change.  ???
I therefore wondered if the script requires all predefined vars to be included in {} operations before it will execute.
Apart from that I cannot see why it didn't execute...  No obvious elements like RUN or END etc jump out at me

Slightly OT

I noticed the 'regex' box in the mass rename dialog is greyed out.  That would be useful for me to have in the future. 
(It wouldn't teach me the MCS however.) :P

The addition of TIME="TODAY" etc functions in my custom search works well btw
The updated in-line rename works well, hadn't noticed the <ctrl> + <e> or <ctrl> + <l> before.  Useful  ;)

Thanks Mathias.

Mathias (Author):

--- Quote from: Ulfhednar on August 07, 2013, 15:01:44 ---I'm wondering about vars & 'scope' (sorry, I wasn't using correct terminology)
As you can see from the screen shot in the post above, the debugger didn't red-flag anything but it didn't rename the selected folder either. 

--- End quote ---
That is because there is no script error.  but I think you are sending the wrong data into RenameFile(...)
Look at the doc http://multicommander.com/docs/multiscript/functions/filesystem#renamefile and and the description of the parameters and what you send, and see if you can see it. :)
 

--- Quote from: Ulfhednar on August 07, 2013, 15:01:44 ---I therefore wondered if the script requires all predefined vars to be included in {} operations before it will execute.
Apart from that I cannot see why it didn't execute...  No obvious elements like RUN or END etc jump out at me

--- End quote ---
The { } are "scopes" for loops or other conditional expressions..  For example if the expression inside an if( ... ) is true the scope belonging to the if is executed. else it is not.
and variables that are defined inside a scope only exists inside that scope. if variable are define in the "global" space then they are accessible by all.
you can write BEGIN / END instead of { } for example
if( $b )
BEGIN
 ...
END

But only boring languages like basic is using that syntax.. { } is used by all modern languages like c/c++/java/js/php and so on.

Ulfhednar:
I have finally grasped which function/call & which token arrangement was needed to get my initial script to apply itself!


--- Code: ---@var $arr = GetSourceSelectedPaths();
@var $items = arrayCount($arr);
@var $CurrentNameFullPath;
@var $OrgName;
@var $NewName;
@var $n = 0;

for( $n = 0; $n < $items; $n++ )
{
  $CurrentNameFullPath = $arr[ $n ];
  $OrgName = PathGetNamePart( $CurrentNameFullPath );
  $NewName = StrReplace( $OrgName, "." , "" );
 
  RenameFile( $arr, $NewName, "SILENT" );
  }
--- End code ---

Now all I have to do is build my regex! :P
I am beginning to see how the different instructions need to be addressed.   

I wonder if there is already a good way to hi-lite the text for ease of editing (I've found with notepad++ I can save as a codepage & get coloured results, eg:- as .pl or .php), which helps me at the moment.

Thanks for your time & tuition Mathias.   :)

*
For regex you mention StrRegExpFind is there also StrRegExpReplace? (If so I haven't seen it in the docs) I am currently assuming that the the find command will then invoke the regex to do any necessary editing.

Mathias (Author):

--- Quote from: Ulfhednar on August 08, 2013, 16:12:25 ---I wonder if there is already a good way to hi-lite the text for ease of editing (I've found with notepad++ I can save as a codepage & get coloured results, eg:- as .pl or .php), which helps me at the moment.

--- End quote ---
Well use an external editor is the option for that.  The built in editor in MC will not support syntax coloring anytime soon. cost so much (in time) to include an edit that support that.


--- Quote from: Ulfhednar on August 08, 2013, 16:12:25 ---For regex you mention StrRegExpFind is there also StrRegExpReplace? (If so I haven't seen it in the docs) I am currently assuming that the the find command will then invoke the regex to do any necessary editing.

--- End quote ---
Only functions you see in doc is there. or in release note for latest beta version if it is a new function.. after final release doc is updated. 

Ulfhednar:

--- Quote ---syntax coloring
--- End quote ---
OK no problem.  I can use my current workaround.  ;)


--- Quote --- new function
--- End quote ---
OK, well I am currently hoping something like the following would work, but it doesn't seem to...


--- Code: ---$NewName = StrReplace( $OrgName, "{((?:[0-9]+)+)\ }", "{((?:[0-9]+)+)\.}");
--- End code ---

Is it just my lack of skill or StrReplace won't accept a regex at all?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version