Page 1 of 1

templates and restful apis

Posted: Tue Jun 07, 2022 3:39 am
by Dino
do you remember templates right?

I found myself using templates for server routines, mthroutines, or just small group of lines that I frequently use, for example:

Code: Select all

Define_Com Class(#XPRIM_OSUtil) Name(#OSUtil)
If (*OSAPI = "IBMI")
#OSUtil.SetEnvironmentVariable Name('LANSA_XLIB_CONFIG') Value('/tmp/lansaxlib.configas400.json')
#OSUtil.SetEnvironmentVariable Name('LANSA_XLIB_TRACEPATH') Value('/LANSA_G14PGMLIB/tmp/log.txt')
Else
#OSUtil.SetEnvironmentVariable Name('LANSA_XLIB_CONFIG') Value('c:\temp\lansaxlib.config.json')
#OSUtil.SetEnvironmentVariable Name('LANSA_XLIB_TRACEPATH') Value('c:\temp\log1.txt')
Endif
every time I want to review the output of a json routine, I need to add those lines. Instead of copy paste from other programs, I just created a new template (File, New, Template), and every time I need that set of lines, I just click the icon for template in the editor, select the respective template, and bring that code into my program.
template01.png
template01.png (25.45 KiB) Viewed 8866 times
some templates make questions and create something more customized, but even the simpler ones with fixed code for example with the typical structure of a restful consumption, reduce my time to coding... just saying.
template02.png
template02.png (67.77 KiB) Viewed 8866 times

Re: templates and restful apis

Posted: Tue Jun 07, 2022 4:03 am
by atostaine
LOL I thought this post was from the future and then I realized it is. This server is on aussie time. :D

Re: templates and restful apis

Posted: Tue Jun 07, 2022 4:55 am
by René Houba
Hi,

I'm almost finished the new LANSA Technical newsletter. In this, I have a tip created by my colleague Jurgen Rentinck where we show a Reusable Part to handle http loggings ;-)

Re: templates and restful apis

Posted: Thu Jun 09, 2022 6:32 am
by adale
One more time saver is that if you have "Auto Complete" turned on, the IDE source editor will recognize your template names just like any other Lansa command. Type in the beginning, or full, template name and press enter, and your source code is populated.