gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
274 stars 61 forks source link

PRINT: Variable is undefined: HELLO error in simple code #1228

Closed isaacdl closed 2 years ago

isaacdl commented 2 years ago

Hi, first of all, sorry for my ignorance. I was requested to install gdl for some work. I installed gdl from bash with sudo apt-get install gnudatalanguage. My simple code is in /home/isaac/blabla

The code is the following one:

print, 'Hello world'
exit

Before trying to run this code I added a new GDL path:

export GDL_PATH="/home/isaac/blabla":gdl -quiet -e 'print, !PATH'``

When I enter gdl and I try to run hello I get this error:

GDL> HELLO
% Parser syntax error: unexpected token: 

  At: /home/isaac/hello.pro, Line 2  Column 11
% PRINT: Variable is undefined: HELLO
% Execution halted at: $MAIN$     

Please, any help would be appreciated. Have a good day fellas.

alaingdl commented 2 years ago

Since your code is neither a procedure or a function, it is nos surprising, from my point of view. If you add "pro hello" at the beginning of the code, I think it will go better.

(Do you speak on IDL/GDL MIRIM code https://arxiv.org/pdf/1810.00894.pdf or on python MIRISIM https://arxiv.org/abs/2010.15710 ? :smile:)

slayoo commented 2 years ago

Thanks for providing the feedback!

When I enter gdl and I try to run hello I get this error:

Does IDL behave differently here?

alaingdl commented 2 years ago

I tested in detail if IDL & (current) GDL are giving same results. Yes !

Three remarks after some tests :

A ref : https://www.l3harrisgeospatial.com/Support/Self-Help-Tools/Help-Articles/Help-Articles-Detail/ArtMID/10220/ArticleID/16156/Quick-tips-for-customizing-your-IDL-program-search-path

HTH

GillesDuvert commented 2 years ago

In addition to what is said above you can put in a file named hello :

print, 'Hello world'
mirim_init
.r mirim_compute_psf
mirim_psf, './configuration/test_psfs.cfg'
exit

and then either

$ gdl
  GDL - GNU Data Language, Version 1.0.1 Git
- For basic information type HELP,/INFO
- Default library routine search path used (GDL_PATH/IDL_PATH env. var. not set): /usr/local/share/gnudatalanguage/lib
- Using WxWidgets as graphics library (windows and widgets).
- Please report bugs, feature or help requests and patches at: https://github.com/gnudatalanguage/gdl

% PREF_SET: Unknown preference: IDL_RBUF_SIZE
% PREF_SET: Unknown preference: IDL_MORE
GDL> @hello
Hello world
(..etc...)

(notice the @)

or gdl -e "@hello" or convert hello in hello.pro and add pro hello as first line, making it a procedure, which can be called as gdl -e "hello"

But of course whatever the way to invoke 'hello', insure the !PATH contains all locations for all procedures needed.

If this is the MIRI package I would expect there exist some general setup procedure that defines everything useful once and for all...

slayoo commented 2 years ago

Still, the error message seems puzling, right?:

At: /home/isaac/hello.pro, Line 2 Column 11

GillesDuvert commented 2 years ago

This is because GDL poorly succeeds to mimic IDL's implied_print new behaviour, by calling 'print,/implied_print' whatever is not a known procedure, etc. In this case, "hello" that was... nothing due to parsing errors.

slayoo commented 2 years ago

Thanks, Gilles. Do we have it described in an issue (cannot find, I guess a good idea to note down)?

isaacdl commented 2 years ago

Hi, thanks for the fast help, was away from laptop. I have tested:

1) add the + before the path. If I type print, !PATH I get this response:

GDL> print, !PATH /home/isaac/blabla:/usr/share/gnudatalanguage/lib/envi:/usr/share/gnudatalanguage/lib/dicom:/usr/share/gnudatalanguage/lib/obsolete:/usr/share/gnudatalanguage/lib Which, from my experience, its correct.

2) I also have tried to add the pro blabla and the end. It's still not working.

3) Yes, added the @ and It worked like a charm. Now I have a problem with astrolib but not gdl stuff, I think I can fix this by myself. Thanks for the help.

Have a good night u all!

slayoo commented 2 years ago

I also have tried to add the pro blabla and the end. It's still not working.

pro needs to be at the beginning of the file, like:


pro test
  print, "test"
end
slayoo commented 2 years ago

the file needs to be named test.pro if the procedure is named test

isaacdl commented 2 years ago

Thanks everybody for the warm help. Merry Christmas!