What should the data returned from a function library be?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

What should the data returned from a function library be?

#1 Post by sunburnt »

There`s a lot of ways to return and use data from functions, the easier to use the better.
My function library can be sourced, or the library executed and the functions called.
I have most all of the functions doing a search and match for partial Xwin. titles.
I`ve gotten the functions to return just values, variable assignments, or evaluated variables.

Some functions return $X, $Y, $W, $H, and maybe the $ID and $TITLE.
Evaluated variables seem the best method here as you know the names of the variables
Also the variables are ready to use and don`t have to be assigned or other code written.

However one of the functions returns info on all the gtkdialog GUIs running.
To evaluate all of the info returned would make for a lot of variables ( 6 per GUI ).
But there`s no way to know what the variables are called as there`s no input arguments.
### Q: Way to get the variables added to the current shell? Command "env" doesn`t do it.
I thought of returning a variable list of the GUI titles which are prepended to the variable names.
Then you could search the list for a match and know the names of each GUIs variables.
But this seems more complex than is needed.
Here it seems best to return a line of values for each gtkdialog GUI running ( the simple way ).
Then the following code can pick out the line it wants and then can parse and use it`s data.

I thought I`d try for a consensus on outputs and maybe even the function names.
Functions so far:
gtkinfo() ... Get info on all gtkdialogs GUIs running.
scrnres() ... Get resolution of desktop / screen.
xtitle() ....... Find the full Xwin. title from part of the title ( validation and auto. completion ).
guiinfo() ... Get info on a GUI by it`s Xwin. title ( perhaps it should do it by ID also ).
dock() ....... Dock a GUI to the right of a running GUI if possible, otherwise on the left.
over() ....... Position a GUI over a running GUI with offsets to line up it`s position.
center() ..... I know that gtkdialog will do this with: ---center , but I included it to be concise.
Along with Screen center, maybe dock to Screen: Left, Right, Top, and Bottom.

I`ve tried to make the library gather as much info by itself as possible, more can be done...
If a child GUI is popped up briefly off screen then it`s size ( W, H ) can be gotten.
gtkdialog doesn`t seem to be any way to have truly hidden or invisible controls and windows.
And if possible I`ll add a function to get the displayed width of a string of text ( idea above ).

Any feedback, suggestions, ideas, or donated code is the whole idea of this post...

Post Reply