CATCH issue in GDL

Help
2010-05-05
2013-06-03
  • Michael Galloy
    Michael Galloy
    2010-05-05

    I would like a way to determine if my code is running in IDL 6.4+ or not, i.e., either GDL or IDL pre-6.4, so that I can use IDLnetURL or not. The straight-forward way of just trying to use IDLnetURL and catching an error if it occurs works in IDL, but not in GDL:

    GDL> print, tx_hasneturl()
    % Compiled module: TX_HASNETURL.
    % Procedure not found: IDLNETURL__DEFINE
    % Execution halted at: TX_HASNETURL        11 tx_hasneturl.pro
    %                      $MAIN$   

    The code just attempts to instantiate IDLnetURL and catches any errors:

    function tx_hasneturl
      compile_opt strictarr

      catch, error
      if (error ne 0L) then begin
         catch, /cancel

         return, 0
      end

      o = obj_new('IDLnetURL')
      obj_destroy, o

      return, 1
    end

    It appears that CATCH does not actually catch the error? Is there a better way? I am on a recent GDL version:

    ~$ gdl
    GDL - GNU Data Language, Version 0.9rc2 CVS

    -Mike

     
  • Sylwester Arabas
    Sylwester Arabas
    2011-06-18

    Mike,

    Very sorry to have left this message unanswered.
    CATCH is not implemented in GDL yet.
    To check for GDL vs. IDL you can use: DEFSYSV, '!GDL', exists=exists

    Sylwester