Aaron,
Without speaking to your illustration of Receive Packet in particular but
to speak more generally you can accomplish much of this sort of
functionality using an IP c-obj.

Since v15 I've started initializing a var called <>appObject on startup.
You can call it anything, of course. Once it's there you can write pretty
much any sort of setters and getters you need to keep track of whatever.
More specific to your example would be a process scope var. I call that one
prosObject and it works exactly the same way.

For example, let's say I want to replace the system OK with my own which
will be boolean. Since this is a process level var I'll use prosObject:

// isOK -> boolean
$0:=ob get(prosObject;"OK";Is boolean)


I suppose that should be 'Get_OK' but I like the shorter version. The
setter would be:

// SET_OK (bool)
ob set(<>appObject;"OK";$1)


Let's say I want to monitor a printing job. Process level again.

// PRINT_SET_printableWidth (longint)
// PRINT_SET_printableHeight (longint)
// PRINT_SET_printedHeight(longint)
and so on with the complimentary getters. For something like this I'd use
Canon Smith's excellent component to allow me to group these things into a
single JSON object most likely called 'printjob' so a setter would look
like:

// PRINT_SET_printableWidth (longint)

Obj_set_long(prosObject;"printjob.printableWidth";$1)

​and the getter:​

// PRINT_GET_printableWidth

Obj_get_long(prosObject;"printjob.printableWidth:)


by doing that I can clean up at the end with

// PRINT_CLEAR

ob remove(prosObject;"printjob")


An aspect of this I like a lot is that I don't have to dedicate specific
variables to those things I need. I also like that I can easily see
everything I have declared in the process by looking at a single variable:
prosObject. Much easier than having to look through the entire database
variable table with I'm trying to troubleshoot something.

And it's easy to extend this idea without a lot of refactoring. Let's say I
want both a process level and an app level OK var. Not sure why but this is
just an example. I could write two different setters and getters or:

// SET_OK (bool;pointer)

// $1 is the value

// $2 is pointer to the obj

ob set($2->;"OK";$1)


Now SET_OK can be used to "OK" in any c-obj. I'm really liking the
flexibility this provides.


On Mon, Aug 29, 2016 at 3:04 PM, Aaron <aaro...@nams-inc.com> wrote:

> Question:
> Will There be a 4D release soon to increase the usage of returned values
> on 4D command, so that I can reduce the reliance on system global process
> variables, like “OK"?
>     a good 4D command canidate is Receive Packet.
> I consider "OK" global variable because it never looses scope, which is
> what a global variable is.
>

-- 
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to