Showing posts with label fis-gtm. Show all posts
Showing posts with label fis-gtm. Show all posts

Saturday, March 15, 2014

Your first GTM module

Let's create a module named 'hello' that can display 'world'.
  1. Start the client: mumps -dir
  2. Edit the file "hello": zed "hello"
  3. Write this code:  say w "hello",! q
  4. Save: :wq
  5. Compile: zl
  6. Run the code: d say^hello
  7. Enjoy !

The code in an indented version
say
  w "hello",!
  q
Here's the session:
#GTM] zed "hello"
[ INSIDE  YOUR $EDITOR ]
[ you save the file    ]
[ and quits the editor ]
#GTM] zl
#GTM] d say^hello
world

#GTM]

Some explanations:
say                   ; Name of the label
  w "hello",!         ; w[rite] the string "hello" followed by end of line: '!'
  q                   ; q[uit] return the control to the caller

You can use the fully qualified name for functions:
say                   ; Name of the label
  write "hello",!     ; w[rite] the string "hello" followed by end of line: '!'
  quit                ; q[uit] return the control to the caller

Egtm (GTM support for Erlang) using UTF-8 chset

If you've already seen this line, you know how this one can be frustrating :)
EGTM Common Error: egtm: 150373066,call^%egtmapi,%GTM-E-INVOBJ, Cannot ZLINK object file due to unexpected format,%GTM-I-TEXT, Object compiled with CHSET=UTF-8 which is different from $ZCHSET

Fighting with GTM to have the UTF8 routines of EGTM, I've finally won the round !
Here's my strategy: in rebar.config add the UTF-8 line ( and set the correct path for your gtm_dist:
{port_envs, [
  %% GT.M flags
  {".*", "gtm_dist", "/opt/application/lib/fis-gtm/V6.0-003_x86_64/utf8"},
  {".*", "gtm_chset", "UTF-8"},
  {".*", "LDFLAGS", "$LDFLAGS -I$gtm_dist -L$gtm_dist -Wl,-rpath -Wl,$gtm_dist -lgtmshr -lc"}
]}.
Then remove the 'egtm_worker.so' from the src directory, and finally recompile:
./rebar comp

Sticky