Page 1 of 1

Warning: Deprecated pre-function commands "broken"

Posted: 01 May 2013 20:36
by TheQwerty
There's been a few reports of broken scripts with the release of v12.40.0000.

I've taken a look at some and it appears to me that with the release of v12.30.0103 something changed in how some deprecated commands work. In particularly this seems to have "broken"* how commands which were converted to functions return their results.

What this means is commands such as GetKey, Replace, RegexReplace, and likely others need to be converted from:

Code: Select all

GetKey $value, $key, $section, $file;
Replace $result, $haystack, $needle, $replacement;
RegexReplace $result, $haystack, $needle, $replacement;
to their function form, including parentheses:

Code: Select all

$value = GetKey($key, $section, $file);
$result = Replace($haystack, $needle, $replacement);
$result = RegexReplace($haystack, $needle, $replacement);

So as a warning to other developers if you have scripts, particularly older ones, which makes use of commands that have since been converted to functions you need to update them!

* Being deprecated means we cannot rely on their existence or previous behavior anymore thus IMO they really can't be broken.
EDIT: And as such I'm not viewing this as a bug - though the lack of mention in the change log better mean it was not intentional. :twisted:

Re: Warning: Deprecated pre-function commands "broken"

Posted: 01 May 2013 21:01
by serendipity
TheQwerty wrote:... though the lack of mention in the change log better mean it was not intentional. :twisted:
:lol: Yes, I went through most changelogs and didn't see a thing about this change.
Thanks for pointing it out.

Re: Warning: Deprecated pre-function commands "broken"

Posted: 01 May 2013 21:24
by admin
Yes, they were deprecated 3.5 years ago. On 20130414 I decided to finally take them out. I should have mentioned it, or I should have taken them out right away after deprecating them.

Re: Warning: Deprecated pre-function commands "broken"

Posted: 01 May 2013 21:31
by TheQwerty
admin wrote:Yes, they were deprecated 3.5 years ago. On 20130414 I decided to finally take them out. I should have mentioned it, or I should have taken them out right away after deprecating them.
So it was intentionally not mentioned - well then shame on you! :naughty: :P

Also shame on us for not updating those scripts in a timely fashion or noticing within the last 2.5 weeks! :oops:


If at all possible, some of the scrambling script writers would probably find a list of the removed commands extremely helpful. ;)

Re: Warning: Deprecated pre-function commands "broken"

Posted: 02 May 2013 01:00
by PeterH
admin wrote:Yes, they were deprecated 3.5 years ago. On 20130414 I decided to finally take them out. I should have mentioned it, or I should have taken them out right away after deprecating them.
I really think it's OK to stop function of these old depracted stuff. Especially where no functionality is lost, but functions just should be used in a better, even more intuitive way.

But in the world of XY scripting, where a lot of people have written a lot of shared scripts over long long times, and often people without knowledge about scripting use them, I think 2 things should have been made:
- info about terminating execution of those commands (for scripters to review),
- and replace the commands, at least for quite some time, with display of an error panel, showing the dropped command, and allowing cancel of the current script.

I've just tested the change with the old form of DiskManager.xys: if I wouldn't have known what happened even I as a scripter would have thought of some "defect", and not of old commands not longer supported...

Re: Warning: Deprecated pre-function commands "broken"

Posted: 02 May 2013 04:02
by TheQwerty
PeterH wrote:But in the world of XY scripting, where a lot of people have written a lot of shared scripts over long long times, and often people without knowledge about scripting use them, I think 2 things should have been made:
- info about terminating execution of those commands (for scripters to review),
- and replace the commands, at least for quite some time, with display of an error panel, showing the dropped command, and allowing cancel of the current script.
I agree with both of these but have two notes for the second.
  1. I feel the stepping dialog should be shown with a warning message starting when the "thing" is deprecated, or at least with the next official release (in this case that would be v12.30.0200).
  2. However, part of the problem in this instance is determining user intent. Remember these were commands converted to functions of the same name, and they could sometimes still be valid calls the way they are used.
I can't check right now, but I'm curious if you try one of these commands with the full set of arguments if they might throw an error about too many arguments?
Or have we already added more arguments to each of these functions leaving them with just as many arguments as, if not more than, their command counterparts?
EDIT: There's no warning for too many arguments so that couldn't have been used to test this.

Re: Warning: Deprecated pre-function commands "broken"

Posted: 02 May 2013 08:40
by admin
OK; next change log:

Code: Select all

    > Scripting: The following commands that have been deprecated on 
      20090917 are not supported anymore since 20130414:
        strlen, strpos, substr, replace, regexreplace, getkey, readurl
      They all have been replace by functions of the same name on 
      20090917.

Re: Warning: Deprecated pre-function commands "broken"

Posted: 15 Sep 2013 04:51
by kiwichick
In view of how many scripts no longer work because of this, and how time consuming it is to go through each script and manually make changes, I've been (with very my limited scripting abilities) trying to figure out a search and replace script to automate some of the process.

I've been using "regexreplace(readfile($file), $search, $replace)" but the problem I'm having is that when something like "$file" is actually one of the search/replace terms it doesn't work because of the $ character. So how would I go about telling the script to ignore all those kinds of special characters?

Cheers :-)

Re: Warning: Deprecated pre-function commands "broken"

Posted: 15 Nov 2013 14:08
by lukescammell
admin wrote:OK; next change log:

Code: Select all

    > Scripting: The following commands that have been deprecated on 
      20090917 are not supported anymore since 20130414:
        strlen, strpos, substr, replace, regexreplace, getkey, readurl
      They all have been replace by functions of the same name on 
      20090917.
If I've read this right, I've replaced:

Code: Select all

strlen $length, $out_item_name;
with:

Code: Select all

$length = strlen($out_item_name);
However, how would I replace this?

Code: Select all

if (strlen($g_list_items) > 1000) {
or this:

Code: Select all

while ($last_slash_index >= 0 && $last_slash_index < strlen($out_item_name)) {
Thanks in advance for any help that can be given.

Re: Warning: Deprecated pre-function commands "broken"

Posted: 15 Nov 2013 14:43
by highend

Code: Select all

if (strlen($g_list_items) > 1000) {
while ($last_slash_index >= 0 && $last_slash_index < strlen($out_item_name)) {
I don't see a reason why there should be anything replaced.
They are used as functions and that's the current implementation.