Pat, you might like to check out the Ada bindings.
Plots. ;-)
Haven't read much yet, so the styling is default. Did change the Hello world to set a window size as it was sized too small to properly show the label for the screen capture. That's about as far as I got in the docs. This is the 15 minute in trial. There is a lot to Agar, a Matrix math and plotting sample will be posted up shortly.
verification pass (doesn't have an event connected to close up shop in this intro sample, so that's kinda borked, ^C to end after using a sysmenu close).
Verfication window from COBOL
Agar test program (which properly closes, event attached it seems - more reading to do). Over 30 test samples in the list.
Picked the widgets test.
Then the plotting test (had to, because charts and graphs, charts and graphs)
Have gooey,
Brian
Last edit: Brian Tiffin 2017-10-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh, one thing I needed to do here to avoid a warning that borked Agar ./configure.
Load up configure and edit -D_BSD_SOURCE to be -D_DEFAULT_SOURCE.
Another tweak was ensuring AG_Config could find test files. I plopped everything in a default ~/.agartest. So create ~/.agartest, and from tests/ just cp *.bmp *.jpg *.png ~/.agartest and cp loss.txt ~/.agartest. There may be other files to copy but I haven't encountered those yet. In test/ the ./agartest program runs all kinds of nifty tests (and a benchmark for the AG_Math utilities).
And here is a better Hello. Baby step two. To be useful this toolkit will need a hefty copylib (or two, or nine).
*>-<**> Author: Brian Tiffin*> Dedicated to the public domain*>*> Date started: October 2017*> Modified: 2017-10-07/23:38-0400 btiffin*>+<**>*> callagar.cob*> Tectonics:*> cobc -xj callagar.cob $(agar-config --libs)*>>>SOURCEFORMATISFREEidentificationdivision.program-id.sample.environmentdivision.configurationsection.repository.functionallintrinsic.datadivision.working-storagesection.01 rcusagebinary-long.01 winusagepointer.01 extraneous-pointerusagepointer.01 pidusagebinary-long.01 argvusagepointer.01 win-downusageprogram-pointer.proceduredivision.sample-main.call "AG_InitCore"usingnullbyvalue1 returningrconexceptiondisplay "error: no libagar"uponsyserrend-callifrc=-1 thendisplay "error: AG_InitCore failure"uponsyserrgobackend-ifcall "AG_InitGraphics"usingbyreferencenullreturningrcifrc=-1 thendisplay "error: AG_InitGraphics failure"uponsyserrgobackend-if*> Execute a command (argv taken from command line (cheating))call "CBL_GC_HOSTED"usingargv"argv"call "AG_Execute"using "/usr/bin/ls"byvalueargvreturningpiddisplay "Pid: "pid*> Create a windowcall "AG_WindowNew"usingbyvalue0 returningwin*> Attach a run downsetwin-downtoentry "windown"ifwin-downequalnullthendisplay "no window rundown"uponsyserrelsecall "AG_SetEvent"usingbyvaluewinbyreference "window-detached"byvaluewin-downbyreferencenullend-if*> Set the size, aligned to top center (2)call "AG_WindowSetGeometryAligned"usingbyvaluewin2 200 100returningomitted*> Simple labelcall "AG_LabelNew"usingbyvaluewin0byreference "Hello, world"returningextraneous-pointer*> display the windowcall "AG_WindowShow"usingbyvaluewinreturningomitted*> run the event loop (run down with sysmenu close)call "AG_EventLoop"returningrcdisplay "Agar rc = "rc*> clean upcall "AG_DestroyGraphics"returningomittedcall "AG_Destroy"returningomittedgoback.endprogramsample.*> **************************************************************identificationdivision.program-id.windown.*> This is a callback from C, and needs an extern call-conventionenvironmentdivision.configurationsection.special-names.call-convention0 isextern.*> passed an eventdatadivision.working-storagesection.01 agar-eventbased.05 event-namepic x(32).05 event-flagsusagebinary-longunsigned.*> more stuff...05 fillerpic x(8192).*> 05 event-function pic x(16). *> or 8?, conditional on long double*> 05 event-argc usage binary-long.*> 05 event-argc0 usage binary-long.*> 05 event-args occurs 16 times.*> 10 *> lots of AG_Variable stuff*> 05 event-events *> and a queue, just to make things harder *> /* Event handler / virtual function */*> typedef struct ag_event {*> char name[AG_EVENT_NAME_MAX]; /* String identifier */*> Uint flags;*> #define AG_EVENT_ASYNC 0x01 /* Service in separate thread */*> #define AG_EVENT_PROPAGATE 0x02 /* Forward to child objs */*> union ag_function fn; /* Callback function */*> int argc, argc0; /* Argument count & offset */*> AG_Variable argv[AG_EVENT_ARGS_MAX]; /* Argument values */*> AG_TAILQ_ENTRY(ag_event) events; /* Entry in Object */*> } AG_Event, AG_Function;linkagesection.01 eventusagepointer.proceduredivisionexternusingbyvalueeventreturningomitted.display "windown: "withnoadvancingifeventnotequalnullthensetaddressofagar-eventtoeventdisplayevent-nameelsedisplayspaceend-if*> window detached, end the event loopcall "AG_Terminate"usingbyvalue0 returningomittedgoback.endprogramwindown.*> test code from http://www.libagar.org/docs/inst/linux.html*> #include <agar/core.h>*> #include <agar/gui.h>*>*> int*> main(int argc, char *argv)*> {*> AG_Window *win;*>*> if (AG_InitCore(NULL, 0) == -1 ||*> AG_InitGraphics(0) == -1) {*> fprintf(stderr, "Init failed: %s\n", AG_GetError());*> return (1);*> }*> win = AG_WindowNew(0);*> AG_LabelNew(win, 0, "Hello, world!");*> AG_WindowShow(win);*> AG_EventLoop();*> return (0);*> }*> $ cc -o hello `agar-config --cflags` hello.c `agar-config --libs`*> AG_SetEvent(win, "window-detached", ConsoleWindowDetached, NULL);
callagar.cob
$ cobc -x -j='-gocart' -debug callagar.cob $(agar-config --libs)
Pid: +0000008546
total 68
-rw-rw-r--. 1 5444 Oct 7 23:49 callagar.cob
-rw-rw-r--. 1 506 Oct 7 23:49 agar-hello.c
-rwxrwxr-x. 1 8944 Oct 7 23:49 agar-hello
drwxr-xr-x. 38 12288 Oct 7 23:49 ..
drwxrwxr-x. 2 4096 Oct 8 00:15 .
-rwxrwxr-x. 1 24280 Oct 8 00:15 callagar
windown: window-detached
Agar rc = +0000000000
Sample. Properly handles the sysmenu close now with a windown event handler.
Verfication window from COBOL
Exercises the AG_Execute function just for fun, which takes a pathname and an argv array; I just cheated and take argv from the main command line, (or in this case the -j= job parameters). Command is /usr/bin/ls and the options end up being -gocart (no group, no owner, ctime, all, reverse (sort), time sort). Easy to remember, shows the last modified files at the bottom, a handy form of ls when working in fatter directories and when your mind is like a sieve of unremembered things, hence the gocart mnemonic.
AG_Event data needs to be expanded on, as does AG_Variable. The structs are kinda hairy but will get a copybook. (Another cheat in this trial, I just gave the event a big bag of empty space, all to get at the first field, the event name).
Cheers,
Brian
Last edit: Brian Tiffin 2017-10-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
vedge (Julian Nadeau) Canadian, so, smart and handsome, by default added a whole suite of non GUI related core materials to Agar with version 1.5
Here is a cross-platform directory listing...
*>-<**> Author: Brian Tiffin*> Dedicated to the public domain*>*> Date started: October 2017*> Modified: 2017-10-08/04:12-0400 btiffin*>+<**>*> agar-dirlist.cob*> Tectonics:*> cobc -xj agar-dirlist.cob $(agar-core-config --libs)*>>>SOURCEFORMATISFREEidentificationdivision.program-id.sample.environmentdivision.configurationsection.repository.functionallintrinsic.datadivision.working-storagesection.01 rcusagebinary-long.01 AG-EXEC-WAIT-INFINITEconstantas1.01 pidusagebinary-long.01 argvusagepointer.01 agar-dir-entriesbased.05 entriesusagepointer.05 num-entriesusagebinary-long.01 agar-dirusagepointer.01 agar-derefusagepointerbased.01 agar-derefedusagepointer.*> Required when CONTENTS-OF not built in01 agar-buffer-namepic x(128)based.01 agar-filenamepic x(128).proceduredivision.sample-main.call "AG_InitCore"usingnullbyvalue1 returningrconexceptiondisplay "error: no libagar"uponsyserrend-callifrc=-1 thendisplay "error: AG_InitCore failure"uponsyserrgobackend-if*> snag a directorycall "AG_OpenDir"using "."returningagar-dirsetaddressofagar-dir-entriestoagar-dirdisplaynum-entries" entries in directory ."setaddressofagar-dereftoentriesperformvaryingtallyfrom1 by1 untiltally>num-entriessetagar-derefedtoagar-deref*> display contents-of(agar-derefed)*> or, without contents-of, do the buffer dancesetaddressofagar-buffer-nametoagar-derefedmovespacestoagar-filenamestringagar-buffer-namedelimitedbylow-valueintoagar-filenamedisplaytrim(agar-filename)setaddressofagar-derefupby8end-performdisplayspace*> Execute a command (argv taken from command line (cheating))call "CBL_GC_HOSTED"usingargv"argv"call "AG_Execute"using "/usr/bin/ls"byvalueargvreturningpiddisplay "Awaiting pid: "pidcall "AG_WaitOnProcess"usingbyvaluepidAG-EXEC-WAIT-INFINITEgoback.endprogramsample.
Pull in (a cross-platform) directory list and display the entries. With an unsorted one per line version of ls to verify.
And here's what it can look like once everyone gets CONTENTS-OF in GnuCOBOL 2.3
(Took out the cruft of the verification pass).
identificationdivision.program-id.sample.environmentdivision.configurationsection.repository.functionallintrinsic.datadivision.working-storagesection.01 rcusagebinary-long.01 agar-dir-entriesbased.05 entriesusagepointer.05 num-entriesusagebinary-long.01 agar-dirusagepointer.01 agar-derefusagepointerbased.proceduredivision.sample-main.call "AG_InitCore"usingnullbyvalue1 returningrconexceptiondisplay "error: no libagar"uponsyserrend-callifrc=-1 thendisplay "error: AG_InitCore failure"uponsyserrgobackend-if*> snag a directorycall "AG_OpenDir"using "."returningagar-dirsetaddressofagar-dir-entriestoagar-dirdisplaynum-entries" entries in directory ."setaddressofagar-dereftoentriesperformuntilagar-derefequalnulldisplaycontents-of(agar-deref)setaddressofagar-derefupbylength(agar-deref)end-performgoback.endprogramsample.
agar-just-dirlist.cob (instead of sliding by 8, this slides by a more appropriate length of a pointer field. Any pointer field will do for the set up by calculation, (seeing as this is aiming for cross-platform)). And by cross-platform, vedge means; X11, Windows, Mac OS/X, SDL and or OpenGL. SDL gives you audio features.
It also just looks for an end of list null while scanning through the char ** array of pointers to names instead of using tally.
vedge (Julian Nadeau) Canadian, so, smart and handsome, by default
Yes of course, Canadian men are known to be handsome, world wide. These
are the men that put us on the map and started the trend:
:-) Handsome, and oh so smart. Coo roo coo coo, coo coo coo coo
Aside: I don't really miss drinking, but I do miss stubbies. Urban myth I heard back in the day was that stubbies were less prone to being used as weapons during bar fights. The new standard long neck bottles seem too easy to grab on to as you drunkenly bash a competitor over the head for the broken glass effect.
More aside: In grade 13 there were enough of us of age that we snuck a Bob and Doug beer tree into the seniour lounge, Principle had to ask us to remove it, but being named O'Keefe and seeing as the tree had many a O'Keefe cap and bottle decoration, the order was delayed for a few days so everyone could admire the art.
Cheers,
Brian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm really starting to think that Agar might be a very appropriate library suite to build into GnuCOBOL for optional graphical SCREEN SECTION. Plus all the other goodies that comes with the kit.
I'd appreciate someone(s) on Windows and Mac giving it a trial, and reporting back.
License is BSD, so friendly, (with the caveat that if you build Agar with AG_Db features you'll be linking to BDB) and you'll have to promise to release sources or pony up with Oracle if you normally build with VBISAM. Releasing source is way better anyway, so... :-)
Cheers,
Brian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How would everyone prefer the tectonics of User Defined Function repository are handled and/or documented?
Link editors can be a pain. cobc can be a breeze or bit of a hassle when putting UDF DSO files to use.
For instance, the upcoming cobweb-agar.cob file is meant to be used as a Dynamic Shared Objects file, so it really should be called libcobweb-agar.cob and produce libcobweb-agar.so, which includes instructions on placing the lib file somewhere in the link search path. (/usr/local/lib for instance). That usually requires root permissions.
Or, a more complex tectonics can be described. For GNU/Linux that would be something like
Note the lib prefix isn't used for the little minus ell option, it's implied in POSIX link rules, but is required in the name of the DSO moved into /usr/local/lib (or where ever you put it).
Just curious on what people think about the issue.
Follow standard trends and assumptions? (lib prefix and ldconfig, ala ./configure)
Make it easy (using the power of cobc and source form builds).
Make it "tricky" and allow personal working dirs and no root powers to explore.
Or, rely on GnuCOBOL environment variables with COB_PRE_LOAD and COB_LIBRARY_PATH?
And there is always the nifty power of building a program-id into UDF repositories that can be used by cobcrun
prompt$ cobc -m cobweb-agar.cob $(agar-config --libs)
prompt$ cobcrun cobweb-agar test
generic: Attach to driver (glx2)
AG_WindowNew: 0x00000000023904a0
AG_Label #0: Attach to window (generic)
agar-win: 0x00000000023904a0
agar-status: 000000256
(Same hello GUI - agar-status is just an internal low-value high-value init completed value in the upcoming cobweb-agar UDF repo (or maybe libcobweb-agar depending on how many people answer this query post)). test is just a command line option read in by the main program-id inside the .so (or .dll what have you for DSO libraries on your platform).
But that cobcrun sequence is more for the author of the DSO and not so much for consumers of the features in a DSO, aside from being an easy way to verify minimal working state and to perhaps get at built in documentation and demos that ship with libraries.
Just asking. I use all of the above methods depending on the wind and phase of moon, but I'd like opinions on what "the one true way" is preferred.
Cheers,
Brian
Last edit: Brian Tiffin 2017-11-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Despite some first tests I wouldn't recompile the library each time from source but compile it once to an object file and add this on the command line.
Personal oppinion:
During test phase: rely on GnuCOBOL environment variables with COB_PRE_LOAD and COB_LIBRARY_PATH (you can very easy change these at any time).
After test phase: mostly unchanged.
For a production version of an external library one may use the standard installation path and add -lname + static calls which has the benefit of verifying during compilation (actual linking) that there are no typos and no functions used that aren't included in the available production library + some minimal speedup on run time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks, Simon. That does seem like the right way, using COB_PRE_LOAD, but I must admit to being a fan of LD_RUN_PATH builds.
Beyond that, should work out some small skeletons of GnuCOBOL related autotools scripts so we can train ourselves to ship these contributions following the ./configure; make paradigm. Perhaps with an eye to having a defacto default gnucobol desktop directory (say ~/.gnucobol) and then set a default install prefix of ~/.gnucobol/ ?? For those times when sudo doesn't feel appropriate.
Autoconf is oh so friendly to work with. <sarc>
Cheers,
Brian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Plotting; there are two main kinds in Agar, FixedPlotter and M_Plotter. This is FixedPlotter. M_Plotter is part of the Agar Matrix subsystem.
prompt$ make test
cobcrun cobweb-agar test
generic: Attach to driver (glx2)
AG_WindowNew: 0x00000000008685c0
AG_Label #0: Attach to window (generic)
AG_FixedPlotter #0: Attach to window (generic)
0x000000000089b0b0
:plot-1:
0x00000000008685c0
Building up the DSO
proceduredivision.acceptclifromcommand-lineifhelpingthendisplay "help"end-ififtestingthenmoveagar-window(AG-WINDOW-CENTER,default-width,default-height)toagar-win-recordmoveagar-fixedplotter(agar-win,AG-PLOTTER-LINES,plotter-flags)toagar-plotter-recordmoveagar-fixedplottercurve(agar-plotter-widget,z"plot-1",agar-red-value,agar-green-value,agar-blue-value,agar-plotter-limit)toagar-curve-recordperformvaryinglooperfrom0 by0.1untillooper>9.3computeagar-16bits=sin(looper)*50moveagar-fixedplotterdatum(agar-curve-widget,agar-16bits)toextraneousend-perform*> display the windowdisplayagar-wincall "AG_WindowShow"usingbyvalueagar-winreturningomitted*> run the event loop until (run down with sysmenu close)call "AG_EventLoop"returningrc*> clean upcall "AG_DestroyGraphics"returningomittedcall "AG_Destroy"returningomitteddisplay "agar-win: "agar-windisplay "agar-status: "ord(agar-status)end-ififversioningthendisplay "cobweb-agar version 0.1 "when-compiledend-ifgoback.endprogramcobweb-agar.
cobweb-agar.cob, starting in on a more full featured UDF DSO.
A neat thing about FixedPlotter, is they are live scrolling widgets that you can drag around. Baby step, this cut uses the default y-range of 100. FixedPlotterDatum is 16-bit signed integer y values, accumulated x vals just by adding points (which can be drawn as lines, shown here).
Lots more to try. The last few calls listed here will be control functions shorty. And the Label will get pulled out of agar-window as a separate feature. Although libagar is "old school" for look and feel, there is a custom style sheet processor too, might try that next. Along with the single and multiline text widgets and some buttons.
Cheers,
Brian
Last edit: Brian Tiffin 2017-10-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's a semi usable alpha cut of cobweb-agar.cob, if not only barely minimal.
*>-<**> Copyright 2017 Brian Tiffin*> Licensed for use under the GNU GPL 3+*> https://www.gnu.org/licenses/gpl-3.0.en.html*> Date: October 2017*> Modified: 2017-10-09/22:16-0400 btiffin*>+<**>*> cobweb-agar.cob: libagar user defined functions*> Tectonics:*> cobc -m cobweb-agar.cob $(agar-config --libs)*>>>SOURCEFORMATISFIXEDidentificationdivision.program-id.cobweb-agar.environmentdivision.configurationsection.repository.functionagar-windowfunctionagar-windowshowfunctionagar-eventloopfunctionagar-boxfunctionagar-labelfunctionagar-buttonfunctionagar-fixedplotterfunctionagar-fixedplottercurvefunctionagar-fixedplotterdatumfunctionallintrinsic.datadivision.REPLACE ==:AGAR-SHARED:==BY==01 agar-statuspic xexternal.88 agar-readyvaluehigh-value.01 rcusagebinary-long.01 extraneoususagebinary-long.01 extraneous-pointerusagebinary-long.01 win-downusageprogram-pointer.====:AGAR-WIDGET-RECORD:==BY==01 agar-widget-record.05 agar-widgetusagepointer.==.working-storagesection.01 cli-commandpic x(16).88 helpingvalues "help","--help","-h".88 versioningvalues "version","--version","-v".88 testingvalues "test","--test","-t".88 repoingvalues "repository","--repo","-r".01 cli-subtextpic x(16).01 window-positions.05 AG-WINDOW-UPPER-LEFTusagebinary-longvalue1.05 AG-WINDOW-UPPER-CENTERusagebinary-longvalue2.05 AG-WINDOW-UPPER-RIGHTusagebinary-longvalue3.05 AG-WINDOW-MIDDLE-LEFTusagebinary-longvalue4.05 AG-WINDOW-CENTERusagebinary-longvalue5.05 AG-WINDOW-MIDDLE-RIGHTusagebinary-longvalue6.05 AG-WINDOW-LOWER-LEFTusagebinary-longvalue7.05 AG-WINDOW-LOWER-CENTERusagebinary-longvalue8.05 AG-WINDOW-LOWER-RIGHTusagebinary-longvalue9.01 box-types.05 AG-BOX-HORIZusagebinary-longvalue0.05 AG-BOX-VERTusagebinary-longvalue1.01 box-flags.05 AG-BOX-HOMOGENOUSusagebinary-longvalue1.05 AG-BOX-HFILLusagebinary-longvalue2.05 AG-BOX-VFILLusagebinary-longvalue4.05 AG-BOX-FRAMEusagebinary-longvalue8.05 AG-BOX-EXPANDusagebinary-longvalue6.01 label-flags.05 AG-LABEL-HFILLusagebinary-longvalueh'01'.05 AG-LABEL-VFILLusagebinary-longvalueh'02'.05 AG-LABEL-NOMINSIZEusagebinary-longvalueh'04'.05 AG-LABEL-PARTIALusagebinary-longvalueh'10'.05 AG-LABEL-REGENusagebinary-longvalueh'20'.05 AG-LABEL-FRAMEusagebinary-longvalueh'80'.05 AG-LABEL-EXPANDusagebinary-longvalueh'03'.01 plotter-types.05 AG-PLOTTER-POINTSusagebinary-longvalue0.05 AG-PLOTTER-LINESusagebinary-longvalue1.01 plotter-flags.05 AG-FIXED-PLOTTER-SCROLLusagebinary-longvalue1.05 AG-FIXED-PLOTTER-XAXISusagebinary-longvalue2.05 AG-FIXED-PLOTTER-HFILLusagebinary-longvalue4.05 AG-FIXED-PLOTTER-VFILLusagebinary-longvalue8.05 AG-FIXED-PLOTTER-EXPANDusagebinary-longvalue12.01 agar-16bitsusagebinary-short.01 looperusagefloat-short.01 agar-win-record.05 agar-winusagepointer.01 agar-box-record.05 agar-box-widgetusagepointer.01 agar-label-record.05 agar-label-widgetusagepointer.01 agar-button-record.05 agar-button-widgetusagepointer.01 agar-plotter-record.05 agar-plotter-widgetusagepointer.01 agar-curve-record.05 agar-curve-widgetusagepointer.:AGAR-SHARED:proceduredivision.acceptcli-commandfromargument-valueifversioningthenperformshow-versionend-ififhelpingthenperformshow-versionperformshow-helpend-ififrepoingthenperformshow-repositoryend-ififtestingthenperformrun-testsend-ifgoback.show-version.display "cobweb-agar version 0.1 "when-compiled.show-help.acceptcli-subtextfromargument-valuecall "SYSTEM"usingconcatenate("sed -n '/\[helpstart-"trim(cli-subtext)"\]/,""/\[helpend-"trim(cli-subtext)"\]/p' "module-source"| sed '1d' | sed '$d' | sed 's/\s*\*>\s//'")*> [helpstart-help]*> cobweb-agar help [topic]*> display help on the given topic*> [helpend-help].show-repository.display "repository."call "SYSTEM"usingconcatenate("grep function-id\\. "module-source" | sed 's/function-id\. /function /'"" | tr '.' ' '").run-tests.moveagar-window(AG-WINDOW-CENTER,numval(200),numval(100))toagar-win-record*> AG-BOX-HFILL + AG-BOX-HOMOGENOUSmoveagar-box(agar-win,AG-BOX-HORIZ,numval(3))toagar-box-recordmoveagar-label(agar-box-widget,numval(0),z"Hello, world")toagar-label-recordmoveagar-button(agar-box-widget,numval(0),z"Goodbye","windown")toagar-button-recordmoveagar-fixedplotter(agar-win,AG-PLOTTER-LINES,numval(15))toagar-plotter-recordmoveagar-fixedplottercurve(agar-plotter-widget,z"plot-1",numval(0),*> rednumval(255),*> greennumval(0),*> bluenumval(2000))*> limittoagar-curve-recordperformvaryinglooperfrom0 by0.1 untillooper>9.3computeagar-16bits=sin(looper)*50moveagar-fixedplotterdatum(agar-curve-widget,agar-16bits)toextraneousend-perform*> display the windowmoveagar-windowshow(agar-win)toextraneous*> run the event loop until run down (close with sysmenu)moveagar-eventloop()torcifrcnotequal0 thendisplay "warning: eventloop non-zero "rcuponsyserrend-if*> clean upcall "AG_DestroyGraphics"returningomittedcall "AG_Destroy"returningomitted.endprogramcobweb-agar.*> ***************************************************************identificationdivision.program-id.windown.*> This is a callback from C, and needs an extern call-conventionenvironmentdivision.configurationsection.special-names.call-convention0 isextern.*> passed an eventdatadivision.working-storagesection.01 agar-eventbased.05 event-namepic x(32).05 event-flagsusagebinary-longunsigned.*> more stuff...05 filler pic x(8192).*> 05 event-function pic x(16). *> or 8?, conditional on long double*> 05 event-argc usage binary-long.*> 05 event-argc0 usage binary-long.*> 05 event-args occurs 16 times.*> 10 *> lots of AG_Variable stuff*> 04 event-events *> and a queue, just to make things harderlinkagesection.01 eventusagepointer.proceduredivisionexternusingbyvalueeventreturningomitted.*> window detached, end the event loopcall "AG_Terminate"usingbyvalue0 returningomittedgoback.endprogramwindown.*> ****************************************************************> [helpstart-window]*> [helpstart-agar-window]*> agar-window(position, width, height)*> create a new top level Agar window*> returning an agar-win-record containing a single pointer*> [helpend-agar-window]*> [helpend-window]identificationdivision.function-id.agar-window.datadivision.working-storagesection.:AGAR-SHARED:linkagesection.01 window-positionusagebinary-long.01 window-widthusagebinary-long.01 window-heightusagebinary-long.01 agar-win-record.05 agar-winusagepointer.proceduredivisionusingwindow-positionwindow-widthwindow-heightreturningagar-win-record.ifnotagar-readythencall "AG_InitCore"usingnullbyvalue1 returningrconexceptiondisplay "error: no libagar"uponsyserrgobackend-callifrcnotequalzerothendisplay "error: AG_InitCore failure"uponsyserrgobackend-ifcall "AG_InitGraphics"usingbyreferencenullreturningrcifrcnotequalzerothendisplay "error: AG_InitGraphics failure"uponsyserrgobackend-ifend-ifsetagar-readytotrue*> Create a windowcall "AG_WindowNew"usingbyvalue0 returningagar-win*> Attach a run downsetwin-downtoentry "windown"ifwin-downequalnullthendisplay "error: windown entry not found"uponsyserrelsecall "AG_SetEvent"usingbyvalueagar-winbyreference "window-detached"byvaluewin-downbyreferencenullend-if*> Set the size, aligned to given positioncall "AG_WindowSetGeometryAligned"usingbyvalueagar-winbyvaluewindow-positionbyvaluewindow-widthbyvaluewindow-heightreturningomittedend-callgoback.endfunctionagar-window.*> ***************************************************************identificationdivision.function-id.agar-windowshow.datadivision.linkagesection.01 agar-parentusagepointer.01 extraneoususagebinary-long.proceduredivisionusingagar-parentreturningextraneous.*> Display Windowcall "AG_WindowShow"usingbyvalueagar-parentreturningomittedmove0 toextraneousgoback.endfunctionagar-windowshow.*> ***************************************************************identificationdivision.function-id.agar-eventloop.datadivision.linkagesection.01 result-codeusagebinary-long.proceduredivisionreturningresult-code.*> Run the event loopcall "AG_EventLoop"returningresult-codegoback.endfunctionagar-eventloop.*> ***************************************************************identificationdivision.function-id.agar-box.datadivision.working-storagesection.:AGAR-SHARED:linkagesection.01 agar-parentusagepointer.01 agar-typeusagebinary-long.01 agar-flagsusagebinary-longunsigned.:AGAR-WIDGET-RECORD:proceduredivisionusingagar-parentagar-typeagar-flagsreturningagar-widget-record.*> Simple labelcall "AG_BoxNew"usingbyvalueagar-parentbyvalueagar-typebyvalueagar-flagsreturningagar-widgetgoback.endfunctionagar-box.*> ***************************************************************identificationdivision.function-id.agar-label.datadivision.working-storagesection.:AGAR-SHARED:linkagesection.01 agar-parentusagepointer.01 agar-flagsusagebinary-longunsigned.01 agar-textpic xanylength.:AGAR-WIDGET-RECORD:proceduredivisionusingagar-parentagar-flagsagar-textreturningagar-widget-record.*> Simple labelcall "AG_LabelNewS"usingbyvalueagar-parentbyvalueagar-flagsbyreferenceagar-textreturningagar-widgetgoback.endfunctionagar-label.*> ***************************************************************identificationdivision.function-id.agar-button.datadivision.working-storagesection.:AGAR-SHARED:01 event-handlerusageprogram-pointer.linkagesection.01 agar-parentusagepointer.01 agar-flagsusagebinary-longunsigned.01 agar-textpic xanylength.01 eventer-namepic xanylength.:AGAR-WIDGET-RECORD:proceduredivisionusingagar-parentagar-flagsagar-texteventer-namereturningagar-widget-record.*> Simple buttoncall "AG_ButtonNewS"usingbyvalueagar-parentbyvalueagar-flagsbyreferenceagar-textreturningagar-widget*> Attach an click handlersetevent-handlertoentryeventer-nameifevent-handlerequalnullthendisplay "error: "eventer-name" not found"uponsyserrelsecall "AG_SetEvent"usingbyvalueagar-widgetbyreference "button-pushed"byvalueevent-handlerbyreferencenullend-ifgoback.endfunctionagar-button.*> ***************************************************************identificationdivision.function-id.agar-fixedplotter.datadivision.working-storagesection.:AGAR-SHARED:linkagesection.01 agar-parentusagepointer.01 agar-fixed-plotter-typeusagebinary-long.01 agar-fixed-plotter-flagsusagebinary-charunsigned.:AGAR-WIDGET-RECORD:proceduredivisionusingagar-parentagar-fixed-plotter-typeagar-fixed-plotter-flagsreturningagar-widget-record.*> Create a fixed plottercall "AG_FixedPlotterNew"usingbyvalueagar-parentbyvalueagar-fixed-plotter-typebyvalueagar-fixed-plotter-flagsreturningagar-widgetgoback.endfunctionagar-fixedplotter.*> ***************************************************************identificationdivision.function-id.agar-fixedplottercurve.datadivision.working-storagesection.:AGAR-SHARED:linkagesection.01 agar-parentusagepointer.01 agar-namepic xanylength.01 agar-redusagebinary-charunsigned.01 agar-greenusagebinary-charunsigned.01 agar-blueusagebinary-charunsigned.01 agar-limitusagebinary-longunsigned.:AGAR-WIDGET-RECORD:proceduredivisionusingagar-parentagar-nameagar-redagar-greenagar-blueagar-limitreturningagar-widget-record.*> Create a fixed plotter curvecall "AG_FixedPlotterCurve"usingbyvalueagar-parentbyreferenceagar-namebyvalueagar-redbyvalueagar-greenbyvalueagar-bluebyvalueagar-limitreturningagar-widgetgoback.endfunctionagar-fixedplottercurve.*> ***************************************************************identificationdivision.function-id.agar-fixedplotterdatum.datadivision.working-storagesection.:AGAR-SHARED:linkagesection.01 agar-parentusagepointer.01 agar-valusagebinary-short.01 unusedusagebinary-long.proceduredivisionusingagar-parentagar-valreturningunused.*> Add a point to a plotter curvecall "AG_FixedPlotterDatum"usingbyvalueagar-parentbyvalueagar-valreturningomittedmove0 tounusedgoback.endfunctionagar-fixedplotterdatum.*> ***************************************************************
cobweb-agar.cob
prompt$ make test
cobc -debug -m cobweb-agar.cob `agar-config --libs`
cobcrun cobweb-agar test
generic: Attach to driver (glx2)
AG_Box #0: Attach to window (generic)
AG_Label #0: Attach to widget (AG_Box #0 in generic)
AG_Label #0: Attach to widget ( in NULL)
AG_Button #0: Attach to widget (AG_Box #0 in generic)
AG_FixedPlotter #0: Attach to window (generic)
build and run a test
prompt$ cobcrun cobweb-agar help agar-window
cobweb-agar version 0.2 2017100922163456-0400
agar-window(position, width, height)
create a new top level Agar window
returning an agar-win-record containing a single pointer
Experimenting with a new embedded help system.
This cut displays a range of lines from the source file (MODULE-SOURCE) given [helpstart-thing] ... [helpend-thing] markers (behind COBOL comment lines), when cobcrun cobweb-agar help thing is given.
In the trial I've wrapped help agar-window inside help window, so you get a reminder of what the real help is (the marker lines) when you use an alias. The short help will likely just mention what man page to look at for the actual Agar manual pages, with a little blurb on the arguments and returns. (Or this kind of embedded help will be dumped for being a useless hassle). Never fear a failed experiment, well, unless you work with explosive chemicals or whatnot.
prompt$ cobcrun cobweb-agar help window
cobweb-agar version 0.2 2017100922321062-0400
[helpstart-agar-window]
agar-window(position, width, height)
create a new top level Agar window
returning an agar-win-record containing a single pointer
[helpend-agar-window]
This help feature may not survive past rev 0.3 of the library, but it's kinda handy. Real ReStructuredText processed output is prettier. ;-)
Does the same kind of extract to get the list of supported functions with
prompt$ cobcrun cobweb-agar repository
repository.
function agar-window
function agar-windowshow
function agar-eventloop
function agar-box
function agar-label
function agar-button
function agar-fixedplotter
function agar-fixedplottercurve
function agar-fixedplotterdatum
repository list taken from scanning the source code.
AG_Textbox is a thing. Based on another thing, an AG_Editable.
Yeah, C structures inside C structures with a few wrinkles with C preprocessor macros.
API looks like, hey just bind a string to your textbox and go. But wait, macros.
Ok, you bind to the editable. And the pointer to that is in the textbox structure just past the ag_widget. Well, what's an ag_widget? Cheated and found out it's an 832 byte area of stuff. So, skip that many bytes and squirrel in to get the editable for binding.
Woohoo. <sarc>
This will all smooth out once the proper copybooks are in place and the structures are coded into workable COBOL, but for the now.
prompt$ make test
cobc -debug -m cobweb-agar.cob `agar-config --libs`
cobcrun cobweb-agar test
...removed Agar debug lines...
work-buffer :This is the ending data :
ending text, after editing the starting text (shown in the screen capture above)
And now it gets real-er.
Events are textbox-return (hit return in a single line text), textbox-prechg (cursoring around), and textbox-postchg (data changed).
The events are posted, and handled like the windown rundown and button-pressed examples; been there, down that, but ... need to figure out how to get at the textbox that triggered the event, then the editable embedded in that textbox and then report that all back for easy use from COBOL while in a subprogram that is called via callback from C.
Not quite there yet; more reading and a pause for station identification. ;-)
Will need to fill in some of the copybooks that these initial trials have been ignoring.
Have good, make deep,
Brian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well then, Robert, perhaps it will be improved and more thought through instead of being dumped. That first cut relies on POSIX utilities so it won't work cross platform.
At the moment it also relies on having access to the source at runtime; might be able to setup a build time tool that extracts pertinent bits and builds the help sections right into the library. Then another step to avoid duplicating effort regarding argument signatures (which always stales rapidly and gets out of whack, which is usually worse than just not being there in the first place).
I've been looking for a reason to put libarchive to more use. Or perhaps assembly files and .incbin and/or objcopy --add-section.
Or, simple, and just pull lines out of source code at runtime. ;-)
Here's an an example using .incbin and symbols included in the DSO library.
Changes the make rule from -m to -b to create a build all module.
Assembler is fairly short (and could be automated along with creation of the text files). I used CamelCase for the symbol names due to lack of hyphen, but could be underscores, as long as there isn't a conflict with any of the actual names generated by cobc for the program at hand.
helpdata.s, could pull in all kinds of *-*-help.txt files.
COBOL gets at the symbol data with a fairly simple:
*> Experiment with embedding .incbin files and symbols in assembly*> see helpdata.s and Makefileifcli-subtextequal "embedded"thensethelptext-entrytoentry "agarWindowHelp"ifhelptext-entrynotequalnullthensethelptexttohelptext-entrydisplaycontents-of(helptext)end-ifend-if
cobweb-agar.cob, help embedded test. (The upcoming contents-of intrinsic won't let you peek at program-pointer data, which is needed for the symbol lookup, so you need a program-pointer and pointer pointer). Without contents-of you need to do the based item / linkage section buffer dance, which isn't too bad. You could also assign a size global symbol in the object code and avoid needing the C string null byte.
prompt$ cobcrun cobweb-agar help embedded
cobweb-agar version 0.2 2017101006305011-0400
agar-window(position, width, height): agar-win-record
creates a new top level Agar window aligned as per position type,
width pixels wide by height pixels high.
Agar man page at "man 3 AG_Window" has more details.
Sample run of embedded text inside object files.
Oh, and I added a help list trial for the source file [helpstart- version, scans through the MODULE-SOURCE file using a grep and sed pipeline.
prompt$ cobcrun cobweb-agar help list
cobweb-agar version 0.2 2017101006420733-0400
List of cobweb-agar help topics:
help
window
agar-window
help list trial.
Have good, make good,
Brian
Last edit: Brian Tiffin 2017-10-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is this horrible? Trying to save some redundant docs
identificationdivision.function-id.agar-combo.datadivision.working-storagesection.:AGAR-SHARED:linkagesection.*> [helpstart-agar-combo]*> function agar-combo(01 agar-parentusagepointer.01 agar-flagsusagebinary-longunsigned.01 agar-textpic xanylength.:AGAR-WIDGET-RECORD:*> )*>*> Create a new combo box. A combo is a high level Agar widget*> that packs a Textbox left of a Button which causes a Tlist*> to popup when pressed. The Tlist disappears when an option*> is selected.*>*> See 'man 3 AG_Combo' for more details.*> [helpend-agar-combo]proceduredivisionusing...
in source help
Shows up like
prompt$ cobcrun cobweb-agar help agar-combo
cobweb-agar [version 0.2] 2017101109384483-0400
function agar-combo(
01 agar-parent usage pointer.
01 agar-flags usage binary-long unsigned.
01 agar-text pic x any length.
:AGAR-WIDGET-RECORD:
)
Create a new combo box. A combo is a high level Agar widget
that packs a Textbox left of a Button which causes a Tlist
to popup when pressed. The Tlist disappears when an option
is selected.
See 'man 3 AG_Combo' for more details.
Might be worth the effort to just add the prototype docs by hand, but this way, even though it looks dorky and is kinda wrong, with the return value inside the parens, it will always be current and the datatypes will be correct.
Could do the same thing a little further down in the procedure division using, but then there are no datatypes shown.
Curious on what people think.
Have good, make lazy,
Brian
Last edit: Brian Tiffin 2017-10-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Looks only horrible concerning the likely REPLACEd :AGAR-..._:. otherwise fine.
But you know how it is "beauty is specific to the person seeing something" :-)
Last edit: Simon Sobisch 2017-10-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Agree on the REPLACE shortcut, these records aren't long enough to warrant the laze.
Already changed to
linkagesection.*> [helpstart-agar-combo]*> function agar-combo(01 agar-parentusagepointer.01 agar-flagsusagebinary-longunsigned.01 agar-labelpic xanylength.*> ) to01 agar-widget-record.05 agar-widgetusagepointer.*>*> Create a new combo box. A combo is a high level Agar widget*> that packs a Textbox left of a Button which causes a Tlist*> to popup when pressed. The Tlist disappears when an option*> is selected.*>*> Add items to the combo list with function agar-tlist-add.*>*> See 'man 3 AG_Combo' and 'man 3 AG_Tlist' for more details.*> [helpend-agar-combo]
in source help
prompt$ cobcrun cobweb-agar help agar-combo
cobweb-agar [version 0.2] 2017101110160357-0400
function agar-combo(
01 agar-parent usage pointer.
01 agar-flags usage binary-long unsigned.
01 agar-label pic x any length.
) to
01 agar-widget-record.
05 agar-widget usage pointer.
Create a new combo box. A combo is a high level Agar widget
that packs a Textbox left of a Button which causes a Tlist
to popup when pressed. The Tlist disappears when an option
is selected.
Add items to the combo list with function agar-tlist-add.
See 'man 3 AG_Combo' and 'man 3 AG_Tlist' for more details.
sample run (still apt to change on way to cobweb-agar [version 0.3]).
The run time help will eventually be embedded in the binary from an automatically generated .incbin assembly file, with a small human readable name to valid symbol name routine. If the few hundred extra K of library size seems burdensome (there will be documentation, but there won't be that much documentation) GnuCOBOL already has a zlib compression module, and source extracted text should compress very well for use from inside the DSO.
Once that works out, then it'll likely be split into two forms of help display based on subcommand. Plain console text and a libagar based graphical help page viewer from a scrollable, with the builtin Ctrl+ Ctrl- zoom features and whatnot (AG_Console is the next up widget). Maybe. This whole experiment could still end up as fail.
Cheers,
Brian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just a note for anyone that may be following along.
Until further notice, all the code samples posted in this thread will be 64-bit only. I'm cheating on a few of the hairier libagar structure definitions and the utilities I'm using (C programs with judicious use of sizeof and offsetof) are reporting filler numbers appropriate for 64-bit machines. I'll make note of the few spots where this is in the code, but until I test some things in a 32-bit VM, I'm just going to assume a 64-bit target.
This will be corrected before cobweb-agar makes it to contributions, with complete structure definitions, and the odd conditional compile sequence, but for now...
When/if Agar is used for internal codegen for graphical SCREEN SECTION none of this warning will apply, as ./configure; make will just do the right thing on the platform at hand. It's just the pure COBOL used while building up a user defined FUNCTION repository that would ever have problems.
There are ways to remove that risk, but more work has to be done first. For now, I'd rather add shiny new widgets to cobweb-agar than fix the plumbing that eventually has to be made cross-platform.
Whinge, whine, excuses excuses. :-)
Cheers,
Brian
Last edit: Brian Tiffin 2017-10-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The easiest "fix" for this is to check P64 via CDF. As long as you don't fix it (possibly by using FILLER USAGE POINTER) you can just add a CDF DISPLAY message there and create a hard error - this ensures that nobody can compile this with 32bit and gets a message why.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was just whinging and whining. Most some of the structs are in now, sync does its job. cobweb-agar will be 32-bit and 64-bit sane after a few more reads and copy-n-pastes from the C headers.
Getting lot's done, going through the widget list alphabetically now. Already up to the "C"s. That's like third from the list of nearly forty ... just flying. :-)
But smart idea on the abort until things are ready. Added, but I did it at runtime along with a mesage during compile.
>>IFP64NOTSET>>DISPLAY "64bit only code at the moment"STOP "Sorry, this codebase currently only supports 64bit, please-"stay tuned. Press Enter to NOT continue."STOPRUN>>END-IF
Code will should compile, but it won't run and risk giving libagar or GnuCOBOL a bad rep.
On that, can we let Edward add the ASSERT verb like he wanted to when he was first coming to grips with the code base? It'd be a handy extension. Plus, I think it'll expose a programmatic way to get at displaying the current source line number for other runtime error and warning messaging.
Or if adding things to the core word set is still not to liking, maybe a >>IMP ASSERT expression?
Cheers,
Brian
Last edit: Brian Tiffin 2017-10-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
libagar is definitely well designed. Events have a big bag of associated data, including a vararg of "variable" data with lots of supported types. "variable" is in quotes, as these are named variables, not just variable data. Common event handlers can query what object raised the event along with named variables which can hold a variety of data types. cobweb-agar will limit that to one integer or one pointer. Buttons can have names and numbers, any widget can have associated events with names and pointers to whatever data you need to pass around. So far. The cobweb-agar API is definitely at risk of changing considerably.
Getting to be over 1,000 lines of code now, so no more full listings here, but current is attached.
prompt$ make helplist
cobc -debug -b cobweb-agar.cob helpdata.o `agar-config --libs`
cobcrun cobweb-agar help list
cobweb-agar [version 0.2] 2017101100175315-0400
List of cobweb-agar help topics:
agar-box
agar-button
agar-label
agar-setevent
agar-setevent-with-field
agar-textbox
agar-window
embedded
help
license
repository
setevent
test
textbox
version
window
prompt$ cobcrun cobweb-agar repository
repository.
function agar-window
function agar-windowshow
function agar-setevent
function agar-setevent-with-field
function agar-eventloop
function agar-box
function agar-label
function agar-button
function agar-textbox
function agar-fixedplotter
function agar-fixedplottercurve
function agar-fixedplotterdatum
some samples
run-tests.moveagar-window(AG-WINDOW-CENTER,numval(200),numval(100))toagar-win-record*> AG-BOX-HFILL + AG-BOX-HOMOGENOUSmoveagar-box(agar-win,AG-BOX-HORIZ,numval(3))toagar-box-recordmoveagar-label(agar-box-widget,numval(0),z"Hello, world")toagar-label-recordmoveagar-button(agar-box-widget,numval(0),z"Goodbye","windown",z"goodbye-button",numval(1))toagar-button-recordmoveagar-textbox(agar-win,numval(0),z"textbox:",work-buffer,"textboxer","agar-text-test")toagar-textbox-recordmoveagar-fixedplotter(agar-win,AG-PLOTTER-LINES,numval(15))toagar-plotter-recordmoveagar-fixedplottercurve(agar-plotter-widget,z"plot-1",numval(0),*> rednumval(255),*> greennumval(0),*> bluenumval(2000))*> limittoagar-curve-recordperformvaryinglooperfrom0 by0.1 untillooper>9.3computeagar-16bits=sin(looper)*50moveagar-fixedplotterdatum(agar-curve-widget,agar-16bits)toextraneousend-perform*> display the windowmoveagar-windowshow(agar-win)toextraneous*> run the event loop until run down (close with sysmenu)moveagar-eventloop()torcifrcnotequal0 thendisplay "warning: eventloop non-zero "rcuponsyserrend-if*> clean upcall "AG_DestroyGraphics"returningomittedcall "AG_Destroy"returningomitted.*> [helpstart-test]*> cobweb-agar test*> Run internal tests, as a demo. Also acts as an example for*> using cobweb-agar features.*>*> See the run-tests paragraph inside the cobweb-agar program.*> [helpend-test]
The code is still covered in construction dust, but
prompt$ cobcrun cobweb-agar help list
cobweb-agar [version 0.2] 2017101119274710-0400
List of cobweb-agar help topics:
agar-box
agar-button
agar-combo
agar-console
agar-consolemsg
agar-dirdlg
agar-filedlg
agar-label
agar-setevent
agar-setevent-with-field
agar-textbox
agar-tlist-add
agar-window
embedded
help
license
repository
setevent
test
textbox
version
window
windowshow
zoom
prompt$ make test
cobcrun cobweb-agar test
field: return-agar-text-test changed 9 times.
textbox buffer now :This is the data 012345 :
shared-data :This is the data 012345 :
As of Oct 11.
Cheers,
Brian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Found another promising GUI kit
http://www.libagar.org/index.html
https://github.com/JulNadeauCA/libagar
Feature complete, C, C++ and Ada
Pat, you might like to check out the Ada bindings.
Plots. ;-)
Haven't read much yet, so the styling is default. Did change the Hello world to set a window size as it was sized too small to properly show the label for the screen capture. That's about as far as I got in the docs. This is the 15 minute in trial. There is a lot to Agar, a Matrix math and plotting sample will be posted up shortly.
callagar.cob
verification pass (doesn't have an event connected to close up shop in this intro sample, so that's kinda borked, ^C to end after using a sysmenu close).
Verfication window from COBOL
Agar test program (which properly closes, event attached it seems - more reading to do). Over 30 test samples in the list.
Picked the widgets test.
Then the plotting test (had to, because charts and graphs, charts and graphs)
Have gooey,
Brian
Last edit: Brian Tiffin 2017-10-07
This is interesting, thanks Brian :)
I will give it a test run and then I will post to the Ada list too, just
in case it could help someone there.
-Pat
Seems interesting!!!
Oh, one thing I needed to do here to avoid a warning that borked Agar ./configure.
Load up configure and edit
-D_BSD_SOURCE
to be-D_DEFAULT_SOURCE
.Another tweak was ensuring AG_Config could find test files. I plopped everything in a default ~/.agartest. So create ~/.agartest, and from tests/ just
cp *.bmp *.jpg *.png ~/.agartest
andcp loss.txt ~/.agartest
. There may be other files to copy but I haven't encountered those yet. Intest/
the./agartest
program runs all kinds of nifty tests (and a benchmark for the AG_Math utilities).And here is a better Hello. Baby step two. To be useful this toolkit will need a hefty copylib (or two, or nine).
callagar.cob
Sample. Properly handles the sysmenu close now with a windown event handler.
Verfication window from COBOL
Exercises the AG_Execute function just for fun, which takes a pathname and an argv array; I just cheated and take argv from the main command line, (or in this case the -j= job parameters). Command is /usr/bin/ls and the options end up being -gocart (no group, no owner, ctime, all, reverse (sort), time sort). Easy to remember, shows the last modified files at the bottom, a handy form of ls when working in fatter directories and when your mind is like a sieve of unremembered things, hence the gocart mnemonic.
AG_Event data needs to be expanded on, as does AG_Variable. The structs are kinda hairy but will get a copybook. (Another cheat in this trial, I just gave the event a big bag of empty space, all to get at the first field, the event name).
Cheers,
Brian
Last edit: Brian Tiffin 2017-10-08
vedge (Julian Nadeau) Canadian, so, smart and handsome, by default added a whole suite of non GUI related core materials to Agar with version 1.5
Here is a cross-platform directory listing...
agar-dirlist.cob
Pull in (a cross-platform) directory list and display the entries. With an unsorted one per line version of ls to verify.
And here's what it can look like once everyone gets CONTENTS-OF in GnuCOBOL 2.3
(Took out the cruft of the verification pass).
agar-just-dirlist.cob (instead of sliding by 8, this slides by a more appropriate length of a pointer field. Any pointer field will do for the
set up by
calculation, (seeing as this is aiming for cross-platform)). And by cross-platform, vedge means; X11, Windows, Mac OS/X, SDL and or OpenGL. SDL gives you audio features.It also just looks for an end of list null while scanning through the
char **
array of pointers to names instead of using tally.Note the agar-core-config, it'll only pull in Agar Core library needs, sans GUI.
Lots more to explore...
Have good, make core, hard core,
Brian
On 10/08/2017 04:38 AM, Brian Tiffin wrote:
https://www.youtube.com/watch?v=w1RN3cYnY9k
-Pat
:-) Handsome, and oh so smart. Coo roo coo coo, coo coo coo coo
Aside: I don't really miss drinking, but I do miss stubbies. Urban myth I heard back in the day was that stubbies were less prone to being used as weapons during bar fights. The new standard long neck bottles seem too easy to grab on to as you drunkenly bash a competitor over the head for the broken glass effect.
More aside: In grade 13 there were enough of us of age that we snuck a Bob and Doug beer tree into the seniour lounge, Principle had to ask us to remove it, but being named O'Keefe and seeing as the tree had many a O'Keefe cap and bottle decoration, the order was delayed for a few days so everyone could admire the art.
Cheers,
Brian
I had my last drink in 2002. Still these these role models so many
qualities :)
My Dad is from Ireland and there are even better role models there:
https://www.youtube.com/watch?v=rECB4u3VOAs
P.S I am old enough to remember when Ontario had grade 13 :)
I'm really starting to think that Agar might be a very appropriate library suite to build into GnuCOBOL for optional graphical SCREEN SECTION. Plus all the other goodies that comes with the kit.
I'd appreciate someone(s) on Windows and Mac giving it a trial, and reporting back.
License is BSD, so friendly, (with the caveat that if you build Agar with AG_Db features you'll be linking to BDB) and you'll have to promise to release sources or pony up with Oracle if you normally build with VBISAM. Releasing source is way better anyway, so... :-)
Cheers,
Brian
How would everyone prefer the tectonics of User Defined Function repository are handled and/or documented?
Link editors can be a pain. cobc can be a breeze or bit of a hassle when putting UDF DSO files to use.
For instance, the upcoming cobweb-agar.cob file is meant to be used as a Dynamic Shared Objects file, so it really should be called libcobweb-agar.cob and produce libcobweb-agar.so, which includes instructions on placing the lib file somewhere in the link search path. (/usr/local/lib for instance). That usually requires root permissions.
Or, a more complex tectonics can be described. For GNU/Linux that would be something like
building the DSO. That part is easy to describe.
The next part, not so much.
Linking to a name without a lib prefix in a personal working direcory.
Or, easier, but harder on compile time (which for cobc is pretty fast)
Just build the library into the executable using the source form
Or, more "standard" POSIX
Note the lib prefix isn't used for the little minus ell option, it's implied in POSIX link rules, but is required in the name of the DSO moved into /usr/local/lib (or where ever you put it).
Just curious on what people think about the issue.
A trial, (current version of libagar built with
./configure --without-db4 --enable-debug
so it logs some messages to stderr (and has no BDB linkage).Here is the procedure division for that demo
cobweb-agar will be fairly concise COBOL.
And there is always the nifty power of building a
program-id
into UDF repositories that can be used bycobcrun
(Same hello GUI - agar-status is just an internal low-value high-value init completed value in the upcoming cobweb-agar UDF repo (or maybe libcobweb-agar depending on how many people answer this query post)).
test
is just a command line option read in by the main program-id inside the .so (or .dll what have you for DSO libraries on your platform).But that cobcrun sequence is more for the author of the DSO and not so much for consumers of the features in a DSO, aside from being an easy way to verify minimal working state and to perhaps get at built in documentation and demos that ship with libraries.
Just asking. I use all of the above methods depending on the wind and phase of moon, but I'd like opinions on what "the one true way" is preferred.
Cheers,
Brian
Last edit: Brian Tiffin 2017-11-07
Despite some first tests I wouldn't recompile the library each time from source but compile it once to an object file and add this on the command line.
Personal oppinion:
During test phase: rely on GnuCOBOL environment variables with
COB_PRE_LOAD
andCOB_LIBRARY_PATH
(you can very easy change these at any time).After test phase: mostly unchanged.
For a production version of an external library one may use the standard installation path and add
-lname
+ static calls which has the benefit of verifying during compilation (actual linking) that there are no typos and no functions used that aren't included in the available production library + some minimal speedup on run time.Thanks, Simon. That does seem like the right way, using COB_PRE_LOAD, but I must admit to being a fan of LD_RUN_PATH builds.
Beyond that, should work out some small skeletons of GnuCOBOL related autotools scripts so we can train ourselves to ship these contributions following the ./configure; make paradigm. Perhaps with an eye to having a defacto default gnucobol desktop directory (say ~/.gnucobol) and then set a default install prefix of ~/.gnucobol/ ?? For those times when sudo doesn't feel appropriate.
Autoconf is oh so friendly to work with. <sarc>
Cheers,
Brian
Plotting; there are two main kinds in Agar, FixedPlotter and M_Plotter. This is FixedPlotter. M_Plotter is part of the Agar Matrix subsystem.
Building up the DSO
cobweb-agar.cob, starting in on a more full featured UDF DSO.
A neat thing about FixedPlotter, is they are live scrolling widgets that you can drag around. Baby step, this cut uses the default y-range of 100. FixedPlotterDatum is 16-bit signed integer y values, accumulated x vals just by adding points (which can be drawn as lines, shown here).
Lots more to try. The last few calls listed here will be control functions shorty. And the Label will get pulled out of agar-window as a separate feature. Although libagar is "old school" for look and feel, there is a custom style sheet processor too, might try that next. Along with the single and multiline text widgets and some buttons.
Cheers,
Brian
Last edit: Brian Tiffin 2017-10-09
Here's a semi usable alpha cut of cobweb-agar.cob, if not only barely minimal.
cobweb-agar.cob
build and run a test
Experimenting with a new embedded help system.
This cut displays a range of lines from the source file (MODULE-SOURCE) given
[helpstart-thing] ... [helpend-thing] markers (behind COBOL comment lines), when
cobcrun cobweb-agar help thing
is given.In the trial I've wrapped
help agar-window
insidehelp window
, so you get a reminder of what the real help is (the marker lines) when you use an alias. The short help will likely just mention what man page to look at for the actual Agar manual pages, with a little blurb on the arguments and returns. (Or this kind of embedded help will be dumped for being a useless hassle). Never fear a failed experiment, well, unless you work with explosive chemicals or whatnot.This help feature may not survive past rev 0.3 of the library, but it's kinda handy. Real ReStructuredText processed output is prettier. ;-)
Does the same kind of extract to get the list of supported functions with
repository list taken from scanning the source code.
Cheers,
Brian
And things just got real. :-( ;-)
AG_Textbox is a thing. Based on another thing, an AG_Editable.
Yeah, C structures inside C structures with a few wrinkles with C preprocessor macros.
API looks like, hey just bind a string to your textbox and go. But wait, macros.
Ok, you bind to the editable. And the pointer to that is in the textbox structure just past the ag_widget. Well, what's an ag_widget? Cheated and found out it's an 832 byte area of stuff. So, skip that many bytes and squirrel in to get the editable for binding.
Woohoo. <sarc>
This will all smooth out once the proper copybooks are in place and the structures are coded into workable COBOL, but for the now.
workaround
ending text, after editing the starting text (shown in the screen capture above)
And now it gets real-er.
Events are textbox-return (hit return in a single line text), textbox-prechg (cursoring around), and textbox-postchg (data changed).
The events are posted, and handled like the windown rundown and button-pressed examples; been there, down that, but ... need to figure out how to get at the textbox that triggered the event, then the editable embedded in that textbox and then report that all back for easy use from COBOL while in a subprogram that is called via callback from C.
Not quite there yet; more reading and a pause for station identification. ;-)
Will need to fill in some of the copybooks that these initial trials have been ignoring.
Have good, make deep,
Brian
I thought it was a good idea and was planning to include it in CobolSQLite3 as an addition to the User Guide.
Well then, Robert, perhaps it will be improved and more thought through instead of being dumped. That first cut relies on POSIX utilities so it won't work cross platform.
At the moment it also relies on having access to the source at runtime; might be able to setup a build time tool that extracts pertinent bits and builds the help sections right into the library. Then another step to avoid duplicating effort regarding argument signatures (which always stales rapidly and gets out of whack, which is usually worse than just not being there in the first place).
I've been looking for a reason to put libarchive to more use. Or perhaps assembly files and .incbin and/or objcopy --add-section.
Or, simple, and just pull lines out of source code at runtime. ;-)
Here's an an example using .incbin and symbols included in the DSO library.
Changes the make rule from -m to -b to create a build all module.
Assembler is fairly short (and could be automated along with creation of the text files). I used CamelCase for the symbol names due to lack of hyphen, but could be underscores, as long as there isn't a conflict with any of the actual names generated by cobc for the program at hand.
helpdata.s, could pull in all kinds of *-*-help.txt files.
COBOL gets at the symbol data with a fairly simple:
cobweb-agar.cob, help embedded test. (The upcoming contents-of intrinsic won't let you peek at program-pointer data, which is needed for the symbol lookup, so you need a
program-pointer
andpointer
pointer). Without contents-of you need to do the based item / linkage section buffer dance, which isn't too bad. You could also assign a size global symbol in the object code and avoid needing the C string null byte.Sample run of embedded text inside object files.
Oh, and I added a
help list
trial for the source file[helpstart-
version, scans through the MODULE-SOURCE file using a grep and sed pipeline.help list trial.
Have good, make good,
Brian
Last edit: Brian Tiffin 2017-10-10
Is this horrible? Trying to save some redundant docs
in source help
Shows up like
Might be worth the effort to just add the prototype docs by hand, but this way, even though it looks dorky and is kinda wrong, with the return value inside the parens, it will always be current and the datatypes will be correct.
Could do the same thing a little further down in the procedure division using, but then there are no datatypes shown.
Curious on what people think.
Have good, make lazy,
Brian
Last edit: Brian Tiffin 2017-10-11
Looks only horrible concerning the likely
REPLACE
d:AGAR-..._:
. otherwise fine.But you know how it is "beauty is specific to the person seeing something" :-)
Last edit: Simon Sobisch 2017-10-11
Agree on the REPLACE shortcut, these records aren't long enough to warrant the laze.
Already changed to
in source help
sample run (still apt to change on way to cobweb-agar [version 0.3]).
The run time help will eventually be embedded in the binary from an automatically generated .incbin assembly file, with a small human readable name to valid symbol name routine. If the few hundred extra K of library size seems burdensome (there will be documentation, but there won't be that much documentation) GnuCOBOL already has a zlib compression module, and source extracted text should compress very well for use from inside the DSO.
Once that works out, then it'll likely be split into two forms of help display based on subcommand. Plain console text and a libagar based graphical help page viewer from a scrollable, with the builtin Ctrl+ Ctrl- zoom features and whatnot (AG_Console is the next up widget). Maybe. This whole experiment could still end up as fail.
Cheers,
Brian
Just a note for anyone that may be following along.
Until further notice, all the code samples posted in this thread will be 64-bit only. I'm cheating on a few of the hairier libagar structure definitions and the utilities I'm using (C programs with judicious use of sizeof and offsetof) are reporting filler numbers appropriate for 64-bit machines. I'll make note of the few spots where this is in the code, but until I test some things in a 32-bit VM, I'm just going to assume a 64-bit target.
This will be corrected before cobweb-agar makes it to contributions, with complete structure definitions, and the odd conditional compile sequence, but for now...
When/if Agar is used for internal codegen for graphical SCREEN SECTION none of this warning will apply, as
./configure; make
will just do the right thing on the platform at hand. It's just the pure COBOL used while building up a user defined FUNCTION repository that would ever have problems.There are ways to remove that risk, but more work has to be done first. For now, I'd rather add shiny new widgets to cobweb-agar than fix the plumbing that eventually has to be made cross-platform.
Whinge, whine, excuses excuses. :-)
Cheers,
Brian
Last edit: Brian Tiffin 2017-10-11
The easiest "fix" for this is to check
P64
via CDF. As long as you don't fix it (possibly by usingFILLER USAGE POINTER
) you can just add a CDFDISPLAY
message there and create a hard error - this ensures that nobody can compile this with 32bit and gets a message why.Will.
I was just whinging and whining.
Mostsome of the structs are in now, sync does its job. cobweb-agar will be 32-bit and 64-bit sane after a few more reads and copy-n-pastes from the C headers.Getting lot's done, going through the widget list alphabetically now. Already up to the "C"s. That's like third from the list of nearly forty ... just flying. :-)
But smart idea on the abort until things are ready. Added, but I did it at runtime along with a mesage during compile.
Code
willshould compile, but it won't run and risk giving libagar or GnuCOBOL a bad rep.On that, can we let Edward add the ASSERT verb like he wanted to when he was first coming to grips with the code base? It'd be a handy extension. Plus, I think it'll expose a programmatic way to get at displaying the current source line number for other runtime error and warning messaging.
Or if adding things to the core word set is still not to liking, maybe a
>>IMP ASSERT expression
?Cheers,
Brian
Last edit: Brian Tiffin 2017-10-11
libagar is definitely well designed. Events have a big bag of associated data, including a vararg of "variable" data with lots of supported types. "variable" is in quotes, as these are named variables, not just variable data. Common event handlers can query what object raised the event along with named variables which can hold a variety of data types. cobweb-agar will limit that to one integer or one pointer. Buttons can have names and numbers, any widget can have associated events with names and pointers to whatever data you need to pass around. So far. The cobweb-agar API is definitely at risk of changing considerably.
Getting to be over 1,000 lines of code now, so no more full listings here, but current is attached.
some samples
The
cobweb-agar test
paragraph.Cheers,
Brian
Last edit: Brian Tiffin 2017-10-11
Getting there.
The code is still covered in construction dust, but
As of Oct 11.
Cheers,
Brian