Warning: Deprecated pre-function commands "broken"

Discuss and share scripts and script files...
TheQwerty
Posts: 4330
Joined: 03 Aug 2007 21:30

Warning: Deprecated pre-function commands "broken"

Postby TheQwerty » 01 May 2013 19:36

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:

serendipity
Posts: 3336
Joined: 07 May 2007 17:14
Location: NJ/NY

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

Postby serendipity » 01 May 2013 20:01

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.

admin
Site Admin
Posts: 41366
Joined: 22 May 2004 15:48
Location: Cologne, Win 8.1
Contact:

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

Postby admin » 01 May 2013 20:24

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.

TheQwerty
Posts: 4330
Joined: 03 Aug 2007 21:30

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

Postby TheQwerty » 01 May 2013 20:31

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. ;)

PeterH
Posts: 2432
Joined: 21 Nov 2005 20:39
Location: Germany

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

Postby PeterH » 02 May 2013 00:00

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...
W7(x64) SP1 German
( +WXP SP3 )

TheQwerty
Posts: 4330
Joined: 03 Aug 2007 21:30

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

Postby TheQwerty » 02 May 2013 03:02

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.
Last edited by TheQwerty on 02 May 2013 11:35, edited 1 time in total.

admin
Site Admin
Posts: 41366
Joined: 22 May 2004 15:48
Location: Cologne, Win 8.1
Contact:

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

Postby admin » 02 May 2013 07:40

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.

kiwichick
Posts: 275
Joined: 08 Aug 2012 03:14

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

Postby kiwichick » 15 Sep 2013 03:51

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 :-)

lukescammell
Posts: 744
Joined: 28 Jul 2006 12:15
Location: Kent, UK
Contact:

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

Postby lukescammell » 15 Nov 2013 14:08

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.
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)

highend
Posts: 5378
Joined: 06 Feb 2011 00:33

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

Postby highend » 15 Nov 2013 14:43

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.
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de


Return to “Script Exchange”



Who is online

Users browsing this forum: No registered users and 1 guest