gdl scripts and OO

Help
seany
2013-12-25
2013-12-26
  • seany
    seany
    2013-12-25

    Hello and Merry Xmas

    I had this as a script file:

    a = [1 , 2 , 3 , 4]
    for i = 0,3 do begin
    print, a[i]
    endfor

    if i save this with the name test. pro and run as gdl test.pro, it tells me that it encountered errors : unknown token FOR and unknwon token EnDFOR.

    adding a pro test header and an end footer reports compilationnot possible, although i am not using the -e option, in single line mode.

    the same script, frominside gdl, with .run test.pro works perfectly

    what is wrong?

    also is there any intro to GDL object oriented programming?

    GDL version 0.9.4 cvs

     
    • On 12/25/2013 02:19 AM, seany wrote:

      Hello and Merry Xmas

      I had this as a script file:

      a = [1 , 2 , 3 , 4]
      for i = 0,3 do begin
      print, a[i]
      endfor

      if i save this with the name test. pro and run as gdl test.pro, it tells me that it encountered errors : unknown token FOR and unknwon token EnDFOR.

      adding a pro test header and an end footer reports compilationnot possible, although i am not using the -e option, in single line mode.

      the same script, frominside gdl, with .run test.pro works perfectly

      what is wrong?

      Use .run script in these case I believe.

      --
      Orion Poplawski
      Technical Manager 303-415-9701 x222
      NWRA/CoRA Division FAX: 303-415-9702
      3380 Mitchell Lane orion@cora.nwra.com
      Boulder, CO 80301 http://www.cora.nwra.com

       
  • Hello,

    I believe the behaviour with test.pro is the same as in IDL - running "gdl test.pro" allows only single-line commands within the script.

    Concerning OOP, I suggest having a look at http://www.exelisvis.com/docs/Object_Oriented_Programm.html (and chapters referenced from "See also" tab).

    HTH,
    Sylwester

     
  • seany
    seany
    2013-12-26

    hi, thanks, but I have another problem.

    consider the following:
    automaticSystem__define.pro : http://pastebin.com/s9uQ0VnD
    rhumba.pro : http://pastebin.com/nmSsMpeY
    runrhumba.pro : http://pastebin.com/hhXJ3nqm

    all in the same directory in my /home where gdl was started.

    i call gdl -q runerhumba.pro

    It tells me that automaticSystem__define is not defined. Execution hated in $MAIN$

    If I run the same code of rhumba.pro in interactive mode, i get first error , in position outputObj = obj_new('automaticSystem') that nullGDL::gettags(...) called. Execution halted in $MAIN$. calling it agaian creat the object detectable by help, outputObj.

    but it is not accessing any methods, such as makeGrid , defined in the same automaticSystem__define.pro classfile. Resolve_all is not a keyword GDL recognizes.

    Where am I going wrong?

     
  • Hi,

    First, making the filename all-lowercase allows gdl to find the __define.pro file automaticaly. Then, without the runrhumba.pro you can do:
    $ gdl -e "rhumba, 'LINESEGMENT'"
    This is consistent with IDL's behaviour.

    Second, the "% AUTOMATICSYSTEM__DEFINE: NullGDL::GetTag(...) called." message is of course not intuitive, but this code deas not run in IDL either:

    $ idl -quiet -e "rhumba, 'LINESEGMENT'"
    % Compiled module: RHUMBA.
    constructing r
    object is a grid
    cell contents given
    creating 1D array like a line segment
    % Compiled module: AUTOMATICSYSTEM__DEFINE.
    % Variable is undefined: <UNDEFINED>.
    % Execution halted at: AUTOMATICSYSTEM__DEFINE    7 /home/pracownicy/slayoo/automaticsystem__define.pro
    %                      OBJ_NEW         
    %                      RHUMBA             37 /home/pracownicy/slayoo/rhumba.pro
    %                      $MAIN$
    

    This has something to do with the [] null values. Apparently, you cannot assign a null value to an abject field. I have no experience with !nulls but it somehow makes sense, as IDL deducts object field types from the structure definition in __define procedure, and the []=!null values do not give any hint on the type.

    HTH,
    Sylwester

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks