Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1129 call - parameter problem in 4.6.0

closed-fixed
nobody
Other (155)
7
6 days ago
2012-05-09
sdfdas
No

using the CALL instruction gives problems: $0 contains the called script's name instead of the first parameter to the script!

so scripts as of 4.4.4 don't work any more...

PS: the scripts in use were nested; tested with WindowsXP

Discussion

  • Ethan Merritt
    Ethan Merritt
    2012-05-09

    Can anyone confirm this on Windows?

    I cannot reproduce it here under linux or using the windows executable running under wine. The call parameters are reported equivalently by gnuplot versions going back as far as 4.0 and including current CVS.

    Are you sure you are seeing the effect of $0 substitution done by gnuplot rather than being done by a command shell? This really sounds like a shell issue.

     
  • Ethan Merritt
    Ethan Merritt
    2012-05-09

    • status: open --> open-works-for-me
     
  • Working just fine here (WIn 7, using the official Win32 binaries of both 4.4.4 and 4.6, both console and GUI versions tested).

    So, to the OP: you'll have to extract a self-contained test case for this problem.

     
  • sdfdas
    sdfdas
    2012-05-10

    Sample for the problem call DOIT.CMD

     
    Attachments
  • sdfdas
    sdfdas
    2012-05-10

    I have uploaded a sample showing, that $0 contains the skript name of the CALL-statement instead of the first parameter to the skript file. Just start doit.cmd and look at the error message. If you use 4.4.4 it works (...ok you would need the data files as well, but as a proof of the bug it should do)

     
  • sdfdas
    sdfdas
    2012-05-10

    • assigned_to: nobody --> sfeam
    • status: open-works-for-me --> open-accepted
     
  • sdfdas
    sdfdas
    2012-05-10

    • status: open-accepted --> open
     
  • sdfdas
    sdfdas
    2012-05-10

    • priority: 5 --> 7
     
  • Ethan Merritt
    Ethan Merritt
    2012-05-10

    1) Your test script cannot work as provided, because it contains a typo in the called file name (NotenLaufbahn_avg_fit_fitAFile.plt.inc instead of NotenLaufbahn_avg_fit_fitAfile.plt.inc)

    2) After correcting that typo, the script still does not run because there is a missing data file.

    3) Please show us the output from running the scripts (after fixing) through 4.4 and 4.6.

    This is far too complicated a test case anyhow. Just run a simple test using two files
    file1.gp:
    print "$$0 = $0"; print "$$1 = $1"; print "$$2 = $2"
    file0.gp:
    call 'file1.gp' Zero One Two

    $ gnuplot_4.6 file0.gp
    $0 = Zero
    $1 = One
    $2 = Two

     
  • Ethan Merritt
    Ethan Merritt
    2012-05-10

    • assigned_to: sfeam --> nobody
    • status: open --> open-works-for-me
     
  • Ethan Merritt
    Ethan Merritt
    2012-05-10

    • labels: 1163686 --> Other
    • status: open-works-for-me --> open
     
  • Ethan Merritt
    Ethan Merritt
    2012-05-10

    OK. I think I have figured out the problem your scripts are hitting.

    In gnuplot 4.4, the parameters $0 $1 etc were preserved across a "call" to another script.
    In version 4.6, the parameters are not preserved. More precisely, the parameters themselves may be preserved, but the _number_ of active parameters is over-written by each new "call" execution. So when one of your scripts (that was itself called with 2 parameters) calls another with zero parameters, after return the first script now acts as if there are still zero parameters. That is, it loses track of the 2 parameters present when it was first entered.

    So yes there is a bug that affects your scripts. I will look into a proper fix.

    Meanwhile, several work-arounds are possible, although I have not tested extensively. The simplest is to stuff some junk parameters at the end of the existing call that has zero parameters. The lower level script being called will ignore them, but the upper level script doing the calling will not see its own number of parameters reset to zero.

    NotenLaufbahn_avg_fit_fitAFile.plt.inc:
    - call 'NotenLaufbahn_avg_fit_start_plt.inc'
    + call 'NotenLaufbahn_avg_fit_start_plt.inc' dummy1 dummy2 dummy3 dummy4

     
  • Ethan Merritt
    Ethan Merritt
    2012-05-10

    • status: open --> pending-fixed
     
  • Ethan Merritt
    Ethan Merritt
    2013-04-08

    • status: pending-fixed --> closed-fixed