Page 25 of 109
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Mon Aug 03, 2009 6:02 pm
by Alterx
ZvezdanD wrote:Alterx wrote:i'd like to Replace one custom field (let's say "Alternative Sort" field) with current value from "Artist" field and i want to swap "Surname, Name" to "Name Surname" (removing ",") but only if there is a "," in the source field
You want to modify two fields in same time using one preset which is not currently possible. However, you could get what you want using two existing presets:
1. Copy the Date when the file is last modified to the Date added field - just change fields with
Into and
From dropdown lists;
2. Swap the last and the first name of the Artist with removed ", ".
Not exaclty... maybe it's my poor english
I want to modify just one field: Custom 5 (Alternative Sort)
Of course i'd like to proceed with a two-step modification: first i replace the Custom Field and then i swap the value in "name surname".
By the way, i can understand the problem is that i will not be able to do this just with one script.... i'll use two script
Maybe this could be a sort of suggestion for further release of the script: the ability to run 1 preset with some other presets as argument (in my example: preset "Change Custom 5 Field" that can run the other two presets one after the other).
Thank you very much for your answer anyway.
Bye
Andrea
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Mon Aug 03, 2009 6:58 pm
by ZvezdanD
Alterx wrote:I want to modify just one field: Custom 5 (Alternative Sort)
I did understand that you want to modify Artist field as well. Well, if you want to modify only Custom field using data from Artist field then it is similar to the "Copy the Artist name to the Custom 3 field with moved prefixes to the end" preset - here is the modified
Replace with string:
Code: Select all
RegSub(oSongData.ArtistName, "(.+?),(\s+)(.+?)($|\s&\s|;\s*)", "$3$2$1$4")
As you could see, the second argument of the RegSub function is same as the
Find what string from the mentioned "Swap the last and the first name" preset and the third argument is same as the
Replace with string from the same preset.
By the way, the suggestions for arguments and multiple presets was several times before and they are in development.
Re: RegSub Help
Posted: Thu Aug 06, 2009 7:00 pm
by CarlitoGil
ZvezdanD wrote:GIL wrote:Do you ever wish you could get the version 35.9 of this script from the year 2025?
I am not sure that (I) understand. Do you want to say that there are too many updates of this script or that its development is too slow?
Too many, too slow? Compared to what?
Is just a thought,
now I say: how can I live or do many things without MM and this script
In the year 2025 with maybe version 35.9 we'll say: how could we have lived with version 3.6? Not that is bad.
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Thu Aug 06, 2009 7:45 pm
by CarlitoGil
Is there any way use variables?
I mean not captured from 'Find What' but to use a part of a VBScript expression
like
Set(Var,Value)
would be nice
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Thu Aug 06, 2009 7:58 pm
by CarlitoGil
Could you make the fields from SongDataDict load from an external file so that any custom order is not lost when updating?
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Thu Aug 06, 2009 9:31 pm
by CarlitoGil
Couldn't wait for the variables, so I added this
Code: Select all
Dim Variables(9)
Function SetVariable(Number,Value)
Variables(Number) = Value
End Function
Could it be added to the official script?
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Fri Aug 07, 2009 9:00 am
by ZvezdanD
GIL wrote:Couldn't wait for the variables, so I added this
Code: Select all
Dim Variables(9)
Function SetVariable(Number,Value)
Variables(Number) = Value
End Function
Could it be added to the official script?
This is very nice suggestion. However, I have another approach which allows to have dynamically adjusted size of array and also allows alphabetical variable names, not only numerical, i.e. you could write something like SetVar("My_variable", "some_value") and GetVar("My_variable"):
Code: Select all
Dim iVariable()
ReDim iVariable(0)
Dim oVariable
Set oVariable = CreateObject("Scripting.Dictionary")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function SetVar(vVarName, vValue)
If VarType(vVarName) = vbInteger Then
If UBound(iVariable) < vVarName Then
ReDim Preserve iVariable(vVarName)
End If
iVariable(vVarName) = vValue
ElseIf oVariable.Exists(vVarName) Then
oVariable.Item(vVarName) = vValue
Else
oVariable.Add vVarName, vValue
End If
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetVar(vVarName)
If VarType(vVarName) = vbInteger Then
If UBound(iVariable) >= vVarName Then
GetVar = iVariable(vVarName)
Else
GetVar = ""
End If
ElseIf oVariable.Exists(vVarName) Then
GetVar = oVariable.Item(vVarName)
Else
GetVar = ""
End If
End Function
By the way, using this code, SetVar("1", "some_value") and SetVar(1, "some_another_value") gives two different values! This is because the first function has alphabetical variable name and the second one has numerical name.
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Fri Aug 07, 2009 10:11 am
by CarlitoGil
you could write something like SetVar("My_variable", "some_value") and GetVar("My_variable")
Will this be in the official script?
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Sat Aug 08, 2009 3:12 am
by ZvezdanD
GIL wrote:Will this be in the official script?
Yes, it will be included. However, I need to think about a proper way for clearing those variables and releasing memory. I think that the best place for this is on the end of the Replace All command function and when closing of Find & Replace dialog box.
Did I say this is a very good suggestion?

I think it could speed up some presets, especially those which have several SQLQuery functions. Thanks so much for this!
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Wed Aug 12, 2009 11:42 pm
by CarlitoGil
"Find what" and "Replace with" fields should use a fixed width font
I like 'Lucida Console', like in notepad
Is there a way for me to do this in the mean time?
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Thu Aug 13, 2009 8:19 am
by ZvezdanD
GIL wrote:"Find what" and "Replace with" fields should use a fixed width font
Yeah, I prefer monospaced fonts for such things like code editing. Unfortunately, combo boxes (dropdown lists with edit field) cannot have changed font. I could replace those combo boxes with simple text boxes, but in such case we could not have a typing history like now.
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Thu Aug 13, 2009 7:48 pm
by CarlitoGil
You may have noticed there's a bug when working with functions that set variables
when using the function
Both truepart and falsepart seem to always be evaluated and call the funtcions in falsepart, like SetVariable, thus setting that variable when it should'nt
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Fri Aug 14, 2009 12:13 am
by ZvezdanD
GIL wrote:You may have noticed there's a bug when working with functions that set variables
when using the function
Both truepart and falsepart seem to always be evaluated and call the funtcions in falsepart, like SetVariable, thus setting that variable when it should'nt
It is not a bug. Visual Basic Language Reference - IIf Function (
http://msdn.microsoft.com/en-us/library ... 71%29.aspx):
The expressions in the argument list can include function calls. As part of preparing the argument list for the call to IIf, the Visual Basic compiler calls every function in every expression. This means that you cannot rely on a particular function not being called if the other argument is selected by Expression.
http://en.wikipedia.org/wiki/IIf:
Another issue with IIf arises because it is a library function: unlike the C-derived conditional operator, both truepart and the falsepart will be evaluated regardless of which one is actually returned.
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Fri Aug 14, 2009 11:46 am
by CarlitoGil
Thanks for the clarification
Obviously, I'm not too familiar with Visual Basic.
I forgot IIf is a custom fuction. Now it makes perfect sense
If you're adding a SetVariables to the script perhaps you should add this
Code: Select all
Function IIfx(expr, truepart, falsepart)
If expr Then
IIfx = Eval(truepart)
Else
IIfx = Eval(falsepart)
End If
End Function
Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]
Posted: Fri Aug 14, 2009 12:37 pm
by ZvezdanD
GIL wrote:If you're adding a SetVariables to the script perhaps you should add this
Code: Select all
Function IIfx(expr, truepart, falsepart)
If expr Then
IIfx = Eval(truepart)
Else
IIfx = Eval(falsepart)
End If
End Function
Nice try, but it is nothing different than existing IIf function. As you could see from M$ description, all arguments (expr, truepart, falsepart) are already evaluated before the function call. So, if you specify some function as argument, VBScript interpreter would evaluate that function first and its result will transfer to the IIf function.