Re: syntax : pointer to an element of a sub-array of 2D array

2017-06-03 Thread Arnaud de Montard via 4D_Tech

> Le 2 juin 2017 à 23:41, Garri Ogata via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> Greetings,
> 
> Using Get pointer is another way of doing as well.


Don't be confident in this, it fails in at least 2 situations:
• compiled if the array is local
• in a host/component context if the variable belongs to "the other"

There is also "API Get Array Item Pointer" from APIpack plugin, but it does not 
work in component/host context too. 

More generally, each time I use "Get pointer" (or "RESOLVE POINTER", similar), 
I feel like being using the "last chance solution". Better to ignore they 
exist. I recently found that in my own old code:
  for($i;1;10)
$var:=Get pointer("myVar"+string($i))
  end for
Shame on me, that's an array. 

I think there is a gap in 4D langage, I'd like 4D to fill it:


-- 
Arnaud de Montard 




**
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
**

Re: Exodus utilities live?

2017-06-03 Thread Bob Finnerty via 4D_Tech
Hi David,

Thanks for asking about my old components - good timing. All my components
(including ones never for sale) are v16 ready, and I've been looking to
upload them as open source once I figured out the right repository. Most
have been kept up to date & debugged, although Freedom of Choice (my
displayList replacement) is long in the tooth and needs to be updated to
use list boxes.

Any thoughts on the right place to have these so the 4D community can best
access them. Looking at GitHub but haven't quite figured it out yet - seems
better for raw code as text rather than 4D packages

Bob Finnerty


On Thu, Jun 1, 2017 at 2:19 PM, David Eddy  wrote:

> Dr Finnerty -
>
> I happily bought & used your Exodus utilities back with 4D v2004.  I would
> love to use them again.  Certainly willing to pay for a current license.
>
> By chance have you been able to modernize them for 4D v16?
>
> 
> David Eddy
> Babson Park, MA
>
> W: 781-455-0949
>
> de...@davideddy.com
>
> 4D Partner




-- 
Bob Finnerty
*Exodus Software*
**
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
**

Re: Macro anyone?

2017-06-03 Thread Bob Finnerty via 4D_Tech
Hi Bob,

Thanks to the (absurd) federal EHR requirements, my old Patient Manager EHR
has become  a dinosaur, but I've been slowly reworking it from 2004 to v16,
as I still need some of its functionality (I working for CHI as a specialty
inpatient hospitalist).

Good to see your still in the 4D world as well

Bob Finnerty

On Wed, May 31, 2017 at 8:28 PM, Robert Livingston 
wrote:

> The final 100 yards using Bob Finnerty's suggestion - (Hey! Finnerty. Glad
> to see still working with 4D!)
>
>
>
> 1. Here is the code (non-pseudo) that you place in your project as a
> Project Method: here called SortMethod. Paste this text in and save it.
>
>
>   // PROJECT METHOD: SortMethod
>   // 
>   // CREATED: 05/31/17, 17:40:22 Robert Livingston
>   // DESCRIPTION: Alphabetically sorts the lines of a method when used in
> a Macro
>   // Call SortMethod from the Macro dropdown in the Method Editor
>
> C_TEXT ($inputText)
> C_TEXT ($sortedText)
>
> C_LONGINT ($FULL_METHOD_TEXT)
> $FULL_METHOD_TEXT:=1
> GET MACRO PARAMETER ($FULL_METHOD_TEXT;$inputText)
>
>   // take the input text and turn it into a Text array
> ARRAY TEXT ($axLineCode;0)
> C_LONGINT ($positionDelimiter)
> C_TEXT ($element)
>
> Repeat
>
>   $positionDelimiter:=Position (Char (Carriage return);$inputText)
>
>   If ($positionDelimiter=0)
>
> If ($inputText#"")  // don't gratuitously add a blank line to the
> array at the end
>   APPEND TO ARRAY ($axLineCode;$inputText)
> End if
>
>   Else
>
> $element:=Substring ($inputText;1; ($positionDelimiter-1))
> $inputText:=Substring ($inputText;$positionDelimiter+1)
>
> If ($element#"")  // filter out blank lines
>   APPEND TO ARRAY ($axLineCode;$element)
> End if
>
>   End if
>
> Until ($positionDelimiter=0)
>
> SORT ARRAY ($axLineCode)
>
> C_LONGINT ($nElement;$totElement)
> $totElement:=Size of array ($axLineCode)
>
> If ($totElement>0)
>
>   $sortedText:=$axLineCode{1}
>
>   For ($nElement;2;$totElement)
> $sortedText:=$sortedText+Char (Carriage return)+$axLineCode{$nElement}
>   End for
>
> Else
>
>   $sortedText:="ALERT("+Char (Double quote)+"Method passed has no
> content"+Char (Double quote)+")"
>
> End if
>
> SET MACRO PARAMETER ($FULL_METHOD_TEXT;$sortedText)
>
>
>
> 2. Here is the Macro that you have in your Macro v2 folder (you can just
> add these lines to any existing Macros.xml that you may have.
>
>
> 
> 
> SortMethod
> 
> 
>
>
> ***************
> ************
>
> To use:
>
> – Be in the method that you wish to sort.
>
> – Call the Macro -- SortMethod -- from the macro dropdown list that is
> part of the method editor.
>
> – Boom, the method is sorted.
>
>
> ***************
> ************
>
> It can be a little disconcerting if you accidentally apply this Macro to
> some random method. It will instantly turn into an alphabetized mess.
> Fortunately, the Undo Command will restore its original state.
>
>
>
> > On May 30, 2017, at 8:39 AM, Bob Finnerty via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> >
> > Hi Chip,
> >
> > Here's the pseudocode:
> >
> > Create a 4d method mySortMethod
> > GET MACRO PARAMETER highlighted text
> > Parse returned text to text array with substring using CR as delimiter
> > Sort array
> > Rebuild method text from array: For(1;$element;size of array())+CR
> > SET MACRO PARAMETER highlighted text
> >
> > Then in your macros.xml v2 file:
> >
> >  >name="Sort method lines"
> >in_toolbar="true"
> >in_menu="true"
> >type_ahead="false"
> >version="2"
> >>
> >mySortMethod
> > 
> >
> > HTH
> >
> > --
> > Bob Finnerty
> > Exodus Software
> > **
> > 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
> > **
> >
> > On Tue, May 30, 2017 at 8:04 AM, Chip Scheide via 4D_Tech <
> > 4d_tech@lists.4d.com> wrote:
> >
> >> Anyone have a macro (or anything else)
> >> which will sort method editor text?
> >>
> >> I have a method which I am using to keep track of other methods I have
> >> worked on.
> >> I would like to sort this list. Currently I am copy/pasting in excel
> >> and sorting and copy/pasting back
> >
> >
>
>


-- 
Bob Finnerty
*Exodus Software*
**
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

Re: v13+ What table does a set belong to?

2017-06-03 Thread Chip Scheide via 4D_Tech
Jeremy -
Thanks - and it looks like a possible solution, 

The rest of this comment is more aimed at the forum post of Olivier (copied 
below) - but
This seems like a LOT of work, much more so that a single call to the server.
and it seems a lot of overhead for every set 'math' operation, for all sets 
involved.

something like (calling your routine 'Test_set'):
if (Test_set(Setname1))
  if (Test_set(Setname2))
if (Test_set(Setname3))
// now all the sets are known valid
   union(Setname1;Setname2;Setname3)
end if
  end if
end if

Olivier's forum post (on my feature request)
During a previous summit pre class, I explain and demonstrate how it's 
dangerous to have the same name for sets of different tables. That's an usual 
explanation of unnecessary exchanges between client and server. 
So it's a good 
practice to put the name of the table inside the name of the set. Thanks to 
this rules you prevent a lot of viscosity and "eliminate issues with 
(accidentally) trying to do set manipulations on sets from different tables". 


This feature request need a call to the server to read the parent table. I 
prefer avoid unnecessary exchanges and read a part of the set name. The read is 
local.


> Hi Chip,
> 
> You could try performing a set operation on a known table set with 
> the unknown set. 
> 
> If the two sets are from **different** tables, the set operation 
> triggers an error. If both sets belong to the **same** table, no 
> error occurs.
> 
> So iterate over each table performing the set operation until you 
> encounter no error.
> 
> Something like this, which I tested before posting. It seems to work.:
> 
> C_LONGINT(error_i)
> C_TEXT($known_empty_set)
> C_TEXT($unknown_set_t)
> C_BOOLEAN($done)
> C_BOOLEAN($found)
> 
> $unknown_set_t:="unknown_set"
> CREATE EMPTY SET([Storage];$unknown_set_t)
> 
> $known_empty_set:=Generate UUID
> $table_i:=0
> Repeat 
>   
>   $table_i:=$table_i+1
>   
>   CREATE EMPTY SET(Table($table_i)->;$known_empty_set)
>   
>   ON ERR CALL("TRAP_ERROR")
>   error_i:=0
>   DIFFERENCE($unknown_set_t;$known_empty_set;$known_empty_set)
>   ON ERR CALL("")
>   
>   If (error_i=0)
>   $found:=True
>   End if 
>   error_i:=0
>   
>   If ($table_i=Get last table number)
>   $done:=True
>   End if 
>   
>   CLEAR SET($known_empty_set)
>   
> Until ($done | $found)
> 
> If ($found)
>   ALERT("Set belongs to "+Table name($table_i)+".")
> Else 
>   ALERT("Cannot determine table owning set.")
> end if
> 
> - Jeremy French
> 
> 
>> On Jun 2, 2017, at 5:22 PM, Chip Scheide via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> Is there *any* way to determine what table a random set belongs to?
> 

Hell is other people 
 Jean-Paul Sartre
**
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
**

v16 Component Compiler error

2017-06-03 Thread Bob Finnerty via 4D_Tech
So, trying to compile a component in v16 and getting repeated error:

0: A method and a variable have the same name: ?

I generally keep my components in the 4D application folder Components.

Unhelpfully, 4D doesn't tell what the conflict is. Oh, and there's no
variable which conflicts with a method name

Tried moving components in and out of this folder, all to no avail.

Never a problem in earlier versions

Anyone else seen this?

-- 
Bob Finnerty
*Exodus Software*
**
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
**

Re: Exodus utilities live?

2017-06-03 Thread Lee Hinde via 4D_Tech
Hi;

I vote for Github. Keisuke Miyako has made it work for him.

And, thanks for looking for ways to share code.

On Jun 3, 2017, at 9:08 AM, Bob Finnerty via 4D_Tech <4d_tech@lists.4d.com> 
wrote:
> 
> Hi David,
> 
> Thanks for asking about my old components - good timing. All my components
> (including ones never for sale) are v16 ready, and I've been looking to
> upload them as open source once I figured out the right repository. Most
> have been kept up to date & debugged, although Freedom of Choice (my
> displayList replacement) is long in the tooth and needs to be updated to
> use list boxes.
> 
> Any thoughts on the right place to have these so the 4D community can best
> access them. Looking at GitHub but haven't quite figured it out yet - seems
> better for raw code as text rather than 4D packages
> 
> Bob Finnerty
> 
> 
> On Thu, Jun 1, 2017 at 2:19 PM, David Eddy  wrote:
> 
>> Dr Finnerty -
>> 
>> I happily bought & used your Exodus utilities back with 4D v2004.  I would
>> love to use them again.  Certainly willing to pay for a current license.
>> 
>> By chance have you been able to modernize them for 4D v16?
>> 
>> 
>> David Eddy
>> Babson Park, MA
>> 
>> W: 781-455-0949
>> 
>> de...@davideddy.com
>> 
>> 4D Partner
> 
> 
> 
> 

**
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
**

Printing ListBox that is longer than a single page

2017-06-03 Thread John Baughman via 4D_Tech
I want to print a form that contains a single listbox. How do I make the list 
box print beyond the first page? Works great if the list fits on a single page, 
but only prints the first page if it is longer.

I have the listbox fully inside the detail area and have tried using PRINT 
SELECTION and Print Form. There is a text variable that needs to print as well 
above the listbox.

Looks like I need to use Print Object but need an example of how/where to use 
it.

Thanks,

John
**
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
**

Re: Printing ListBox that is longer than a single page

2017-06-03 Thread John Baughman via 4D_Tech
OK. I got it working. Perhaps this might be of help to someone else in the 
future.

My list box is an array based list box which is being populated at print time. 
The listbox on load form event uses LISTBOX INSERT COLUMN and a few object 
commands to build the listbox with previously populated arrays. I got it to 
work with the following…

PRINT SETTINGS
$printed:=0
If (ok=1)
OPEN PRINTING JOB
If (ok=1)
FORM 
LOAD([_Constants];"HouseCallsFirstNames.Print")

Repeat 
$end:=Print 
object(*;"HCFirstNameReport")

If (Not($end))
LISTBOX GET 
PRINT INFORMATION(*;"HCFirstNameReport";lk last printed row number;$printed)

If ($printed=42)
PAGE 
BREAK

End if 

End if 

Until ($end)

End if 

CLOSE PRINTING JOB

End if 

Note that for this to work the loading of the listbox has to be in the listbox 
on load event, not the forms on load event.

John





> On Jun 3, 2017, at 12:03 PM, John Baughman via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> I want to print a form that contains a single listbox. How do I make the list 
> box print beyond the first page? Works great if the list fits on a single 
> page, but only prints the first page if it is longer.
> 
> I have the listbox fully inside the detail area and have tried using PRINT 
> SELECTION and Print Form. There is a text variable that needs to print as 
> well above the listbox.
> 
> Looks like I need to use Print Object but need an example of how/where to use 
> it.
> 
> Thanks,
> 
> John
> **
> 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
> **

**
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
**

Re: Exodus utilities live?

2017-06-03 Thread Kirk Brooks via 4D_Tech
I suggest github as well. Like Lee said you can look at Miyako's account
and see how to do it.

On Sat, Jun 3, 2017 at 10:08 AM, Bob Finnerty via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi David,
>
> Thanks for asking about my old components - good timing. All my components
> (including ones never for sale) are v16 ready, and I've been looking to
> upload them as open source once I figured out the right repository. Most
> have been kept up to date & debugged, although Freedom of Choice (my
> displayList replacement) is long in the tooth and needs to be updated to
> use list boxes.
>
> Any thoughts on the right place to have these so the 4D community can best
> access them. Looking at GitHub but haven't quite figured it out yet - seems
> better for raw code as text rather than 4D packages
>
> Bob Finnerty
>
>
> On Thu, Jun 1, 2017 at 2:19 PM, David Eddy  wrote:
>
> > Dr Finnerty -
> >
> > I happily bought & used your Exodus utilities back with 4D v2004.  I
> would
> > love to use them again.  Certainly willing to pay for a current license.
> >
> > By chance have you been able to modernize them for 4D v16?
> >
> > 
> > David Eddy
> > Babson Park, MA
> >
> > W: 781-455-0949
> >
> > de...@davideddy.com
> >
> > 4D Partner
>
>
>
>
> --
> Bob Finnerty
> *Exodus Software*
> **
> 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
> **




-- 
Kirk Brooks
San Francisco, CA
===

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**
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
**

Re: v16 Component Compiler error

2017-06-03 Thread Kirk Brooks via 4D_Tech
Bob,
Does the component you are compiling call any other components?

On Sat, Jun 3, 2017 at 12:31 PM, Bob Finnerty via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> So, trying to compile a component in v16 and getting repeated error:
>
> 0: A method and a variable have the same name: ?
>
> I generally keep my components in the 4D application folder Components.
>
> Unhelpfully, 4D doesn't tell what the conflict is. Oh, and there's no
> variable which conflicts with a method name
>
> Tried moving components in and out of this folder, all to no avail.
>
> Never a problem in earlier versions
>
> Anyone else seen this?
>
> --
> Bob Finnerty
> *Exodus Software*
> **
> 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
> **




-- 
Kirk Brooks
San Francisco, CA
===

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**
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
**

Re: v16 Component Compiler error

2017-06-03 Thread Bob Finnerty via 4D_Tech
Well, yes

But I may have stumbled on the answer: It seems to be related in some way
to 4DPop - when I remove these components, the error disappears..

Not sure why, exactly

Bob

On Sat, Jun 3, 2017 at 5:27 PM, Kirk Brooks via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Bob,
> Does the component you are compiling call any other components?
>
> On Sat, Jun 3, 2017 at 12:31 PM, Bob Finnerty via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
>
> > So, trying to compile a component in v16 and getting repeated error:
> >
> > 0: A method and a variable have the same name: ?
> >
> > I generally keep my components in the 4D application folder Components.
> >
> > Unhelpfully, 4D doesn't tell what the conflict is. Oh, and there's no
> > variable which conflicts with a method name
> >
> > Tried moving components in and out of this folder, all to no avail.
> >
> > Never a problem in earlier versions
> >
> > Anyone else seen this?
> >
> > --
> > Bob Finnerty
> > *Exodus Software*
> > **
> > 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
> > **
>
>
>
>
> --
> Kirk Brooks
> San Francisco, CA
> ===
>
> *The only thing necessary for the triumph of evil is for good men to do
> nothing.*
>
> *- Edmund Burke*
> **
> 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
> **




-- 
Bob Finnerty
*Exodus Software*
**
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
**

Re: v16 Component Compiler error

2017-06-03 Thread Kirk Brooks via 4D_Tech
Bob,
I'm betting that one of the components has the offending culprit in it -
either a variable name or method name. And the method may be invisible
which makes it even more challenging to identify.

On Sat, Jun 3, 2017 at 8:41 PM, Bob Finnerty via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Well, yes
>
> But I may have stumbled on the answer: It seems to be related in some way
> to 4DPop - when I remove these components, the error disappears..
>
> Not sure why, exactly
>

-- 
Kirk Brooks
San Francisco, CA
===

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**
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
**

Custom comments: Lots of tips, more wanted!

2017-06-03 Thread David Adams via 4D_Tech
I'm looking at custom constants again and have put together some thoughts.
I wanted to post them here for the sake of the archives, and to solicit
expansions, corrections, tips and the like. If you've got anything to add,
please contribute!

Here goes:

* Right now, not that many people are using thread-safe processes in V16,
but that will change. One of the limits of preemptive mode is that you
cannot use IP variables. For a lot of existing 4D systems, IP variables
have been used instead of custom constants. So, going forward, making
custom constants easier to love is a Very Good Thing.

* Custom constants are great, but they can be a bit of a pain...so they
aren't used as universally as they could be. (Should be?)

* One of the pains is that you have to reopen the database to see custom
constant modifications. *This makes sense.* Constants are values that
cannot change at runtime, so 4D loads them once at startup before our code.
*But this is a pain.* If you agree, please vote in favor of this feature
request:

  Please add a 'Reload constants' command
  http://forums.4d.fr/Post/EN/19514761/1/19514762

* 4D supports custom constants of the simple types Longint, Real, and
String.

* Boolean would be a big help, please vote in favor of this idea here:

  Please add support for custom constants of type Boolean
  http://forums.4d.fr/Post/EN/19514786/1/19514787

* Constants are better than static variables because no lookup,
initialization, etc. needs to be done. The value is set once and that's it.
In a compiled application, the value of the constant is baked right into
the code. So, you can throw away a constants file from a deployed component
or application.

* Duplicate constants are a Very Bad Thing. With that in mind:
-- Remove constants from compiled components. Helpful.
-- Consider a naming starting constants like K_ or your initials, a module
prefix, or a program-specific prefix.


* 4D Pop works fine, but then the constants definition is not in your code.
Alternatively, Jim Dorrance has posted some constants management code here
and Cannon Smith includes custom constants code in some of his (free)
modules. I'm using Cannon's code at the moment and it has made my life a
*lot* better. No criticism of 4D Pop (none! I'm grateful), but I find it
easier (a lot easier) to have everything in the code.

* Sigh. Constant names/labels are limited to 31 characters. Why? No idea.
If you agree that this limit is too low, please vote in favor of this
request:

Raise the 31 character name limit on methods
http://forums.4d.fr/Post/EN/18946884/1/18946885

It's on 4 stars with 56 votes. Four more and it hits 60 votes!

P.S. If you don't think 31 characters is too low a limit for names, you are
a monster. Just saying.


What have I missed? Been misleading about? Been wrong about? Please post
tips, corrections, suggestions, etc.
**
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
**

Re: Custom comments: Lots of tips, more wanted!

2017-06-03 Thread David Adams via 4D_Tech
Forgot to say:

* Constants for numeric codes are great as they make the code a whole lot
easier to read:

$error_level:=5

Well that's good to know...I guess. Is that good or bad? With a custom
consant:

$error_level:=Error level is fatal

Oh, that makes more sense.

* Constants for strings as they make @$%@#$%@#% stupid errors from typos a
thing of the past, well, at least where they use them. This is super
helpful when working with property names in C_OBJECT. (Really what we need
are definable schemas for C_OBJECT contents that the compiler checks -
custom types - but that's a whole different discussion.)

More examples? Good uses?
**
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
**

Re: Custom comments: Lots of tips, more wanted!

2017-06-03 Thread Kirk Brooks via 4D_Tech
David,


On Sat, Jun 3, 2017 at 10:30 PM, David Adams via 4D_Tech <
4d_tech@lists.4d.com> wrote:
>
> * Constants for strings as they make @$%@#$%@#% stupid errors from typos a
> thing of the past, well, at least where they use them. This is super
> helpful when working with property names in C_OBJECT. (Really what we need
> are definable schemas for C_OBJECT contents that the compiler checks -
> custom types - but that's a whole different discussion.)
> ​
>
​Agree. ​
​Since I've been using c-obj more and more for parameter passing and just
general data handling in memory I've started using constants more than
before for object keys exactly because of the need for keys to be exact.
With constants the key label can be more semantic (ie: module specific
thingy name) even when the actual key is more generic (ie: "name").

And you suggestion for being able to re-load constants is good.

You know what else would be good is if constants weren't stored in
Resources but in a separate Constants folder. Why? Because they don't need
to ship with the db if it's compiled and it's a pain to remember to remove
them after building the compiled app.

And ultimately it would be preferable for them to be integral to 4D rather
than as an add on. ​

-- 
Kirk Brooks
San Francisco, CA
===

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**
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
**

Re: Custom comments: Lots of tips, more wanted!

2017-06-03 Thread David Adams via 4D_Tech
On Sun, Jun 4, 2017 at 2:40 PM, Kirk Brooks via 4D_Tech <
4d_tech@lists.4d.com> wrote:


> ​Since I've been using c-obj more and more for parameter passing and just
> general data handling in memory I've started using constants more than
> before for object keys exactly because of the need for keys to be exact.
> With constants the key label can be more semantic (ie: module specific
> thingy name) even when the actual key is more generic (ie: "name").
>

You've been mentioning this for some time and I eventually came around to
your point of view. 100% agreed.


> And you suggestion for being able to re-load constants is good.
>

I'm not sure what it entails on a technical level for 4D but, hopefully,
it's an easy one.


> You know what else would be good is if constants weren't stored in
> Resources but in a separate Constants folder. Why? Because they don't need
> to ship with the db if it's compiled and it's a pain to remember to remove
> them after building the compiled app.
>

Huh, interesting idea. Do you mid submitting that as a feature request and
see what we get back? I think what I'd ask for is along the lines of a
build option "Delete constants from built application/component". Something
like that. What do you think? Either way, please put in a feature request
for what you like and post a notice here so that those of us interested in
the subject can vote.


> And ultimately it would be preferable for them to be integral to 4D rather
> than as an add on. ​
>

Agreed. I've thought so since custom constants were first available in 4D
6.5. Holding breath.I think that would mean storing them in the
struture, which has some downsides and doesn't seem to be the way 4D is
heading. I'm not sure how best they could integrate them natively in
design, but it sure would be nicer. Maybe some kind of define statement?

Define(Theme;Label;Value) // Value can be Long, String, Real, or Boolean

Define("Error Constants";"Error level is informational";1)
Define("Error Constants";"Error level is warning";2)
Define("Error Constants";"Error level is error";3)
Define("Error Constants";"Error level is critical";4)
Define("Error Constants";"Error level is fatal";5)

Thoughts?
**
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
**