Re: Constants in code.

2019-12-10 Thread Jim Hays via 4D_Tech
+10 for Cannon and David Adams' code.
Clear and simple.

On Mon, Dec 9, 2019 at 11:40 AM Cannon Smith via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi Eric,
>
> There is also a way to create constants in your code if you want. There is
> a tech note about it here:
>
> <https://kb.4d.com/assetid=77806>
>
> HTH.
>
> --
> Cannon.Smith
> Synergy Farm Solutions Inc.
> Aetna, AB Canada
> 
> 
>
>
> > On Dec 9, 2019, at 8:09 AM, Eric Naujock via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> >
> > Can you define your own Constants? I would like to define constants in
> my database to cover various groups for permissions. But what I am finding
> in the docs for v17r6 says they are listed in the constants window. But
> there does not seem to be anything that tells you how to create your own.
> Obviously there must be a way to do so since there are constants for
> plugins.
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Constants in code.

2019-12-09 Thread Chip Scheide via 4D_Tech
Kirk,
yes you can  :)

As I said in my post - I modified 4DPop constant editor do just that (among 
other things)

Chip
 

> I'll add a vote for Cannon's code for creating constant XLIF files. I
> really like being able to add comments to what the constants are for in the
> code. You just can't do that with the 4DPOP component.

Hell is other people 
 Jean-Paul Sartre
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Constants in code.

2019-12-09 Thread Eric Naujock via 4D_Tech
I have downloaded it and played with it a bit. It looks interesting. I think I 
may add the constants_rebuildall to my post backup script. This way I can be 
sure my constants are always deployed, At least after a backup. Since the 
script takes almost no time but the time gains with the constants are enormous.

When the backup is run most users should not be logged in anyways.

> On Dec 9, 2019, at 4:40 PM, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Eric,
> I'll add a vote for Cannon's code for creating constant XLIF files. I
> really like being able to add comments to what the constants are for in the
> code. You just can't do that with the 4DPOP component.
> 
> On Mon, Dec 9, 2019 at 9:55 AM Eric Naujock via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> 
>> Thanks I downloaded the document. Reading into it. Hopefully it still
>> works for the new 4D Projects system. I am looking forward to being able to
>> use GIT to manage my 4D projects. Versioning.
>> 
>>> On Dec 9, 2019, at 11:40 AM, Cannon Smith <
>> can...@synergyfarmsolutions.com> wrote:
>>> 
>>> Hi Eric,
>>> 
>>> There is also a way to create constants in your code if you want. There
>> is a tech note about it here:
>>> 
>>>  <https://kb.4d.com/assetid=77806>
>>> 
>>> HTH.
>>> 
>>> —
>>> Cannon.Smith
>>> Synergy Farm Solutions Inc.
>>> Aetna, AB Canada
>>> 
>>> 
>>> 
>>> 
>>>> On Dec 9, 2019, at 8:09 AM, Eric Naujock via 4D_Tech <
>> 4d_tech@lists.4d.com> wrote:
>>>> 
>>>> Can you define your own Constants? I would like to define constants in
>> my database to cover various groups for permissions. But what I am finding
>> in the docs for v17r6 says they are listed in the constants window. But
>> there does not seem to be anything that tells you how to create your own.
>> Obviously there must be a way to do so since there are constants for
>> plugins.
>>> 
>> 
>> **
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
>> **
> 
> 
> 
> -- 
> Kirk Brooks
> San Francisco, CA
> ===
> 
> What can be said, can be said clearly,
> and what you can’t say, you should shut up about
> 
> *Wittgenstein and the Computer *
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Constants in code.

2019-12-09 Thread Kirk Brooks via 4D_Tech
Eric,
I'll add a vote for Cannon's code for creating constant XLIF files. I
really like being able to add comments to what the constants are for in the
code. You just can't do that with the 4DPOP component.

On Mon, Dec 9, 2019 at 9:55 AM Eric Naujock via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Thanks I downloaded the document. Reading into it. Hopefully it still
> works for the new 4D Projects system. I am looking forward to being able to
> use GIT to manage my 4D projects. Versioning.
>
> > On Dec 9, 2019, at 11:40 AM, Cannon Smith <
> can...@synergyfarmsolutions.com> wrote:
> >
> > Hi Eric,
> >
> > There is also a way to create constants in your code if you want. There
> is a tech note about it here:
> >
> >   <https://kb.4d.com/assetid=77806>
> >
> > HTH.
> >
> > —
> > Cannon.Smith
> > Synergy Farm Solutions Inc.
> > Aetna, AB Canada
> > 
> > 
> >
> >
> >> On Dec 9, 2019, at 8:09 AM, Eric Naujock via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> >>
> >> Can you define your own Constants? I would like to define constants in
> my database to cover various groups for permissions. But what I am finding
> in the docs for v17r6 says they are listed in the constants window. But
> there does not seem to be anything that tells you how to create your own.
> Obviously there must be a way to do so since there are constants for
> plugins.
> >
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
Kirk Brooks
San Francisco, CA
===

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Constants in code.

2019-12-09 Thread Eric Naujock via 4D_Tech
Thanks I downloaded the document. Reading into it. Hopefully it still works for 
the new 4D Projects system. I am looking forward to being able to use GIT to 
manage my 4D projects. Versioning.

> On Dec 9, 2019, at 11:40 AM, Cannon Smith  
> wrote:
> 
> Hi Eric,
> 
> There is also a way to create constants in your code if you want. There is a 
> tech note about it here:
> 
>   <https://kb.4d.com/assetid=77806>
> 
> HTH.
> 
> —
> Cannon.Smith
> Synergy Farm Solutions Inc.
> Aetna, AB Canada
> 
> 
> 
> 
>> On Dec 9, 2019, at 8:09 AM, Eric Naujock via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> Can you define your own Constants? I would like to define constants in my 
>> database to cover various groups for permissions. But what I am finding in 
>> the docs for v17r6 says they are listed in the constants window. But there 
>> does not seem to be anything that tells you how to create your own. 
>> Obviously there must be a way to do so since there are constants for 
>> plugins. 
> 

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Constants in code.

2019-12-09 Thread Cannon Smith via 4D_Tech
Hi Eric,

There is also a way to create constants in your code if you want. There is a 
tech note about it here:

<https://kb.4d.com/assetid=77806>

HTH.

--
Cannon.Smith
Synergy Farm Solutions Inc.
Aetna, AB Canada




> On Dec 9, 2019, at 8:09 AM, Eric Naujock via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Can you define your own Constants? I would like to define constants in my 
> database to cover various groups for permissions. But what I am finding in 
> the docs for v17r6 says they are listed in the constants window. But there 
> does not seem to be anything that tells you how to create your own. Obviously 
> there must be a way to do so since there are constants for plugins. 

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Constants in code.

2019-12-09 Thread Eric Naujock via 4D_Tech
Thanks. I would appreciate having the new 4D Pop. 

> On Dec 9, 2019, at 10:44 AM, Chip Scheide via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> to expand
> you can create 1 or more constants files in xlif format.
> Inside each constants file you can create 'groups', logic assemblages 
> of constants.
> i.e. Web_Display, Interface_Colors, Listbox_Properties,  etc.
> 
> There is a tool in 4DPop (4Dpop constants editor) to help with this 
> process.
> 
> The constant file(s) are then placed next to the structure in a folder 
> titled "Constants". This folder may not already exist and you may have 
> to create it. On a Mac you need to open the structure package (show 
> package contents) to create/modify the Constants folder.
> 
> If you , or anyone else is interested, I have a version of 4DPop 
> constants editor that I have modified to include the following 
> enhancements (currently in v15 can/should be updatable to any newer 
> version):
> [send me an email making the request - and I'll send the modified 4DPop 
> source code along.]
> 
> - open xlif files NOT in the current structure's path. i.e. open any 
> xlif file, anywhere.
> - drag n drop xlif files (as part of above).
> - show all constants as a single list when there are groupings inside 
> an xlif file, The constants are Not savable, including full sort order, 
> in this 'mode'.
> - able to re-load an xlif file, if modified by an outside program (i.e. 
> text editor).
> - sort (permanently if saved) not only the groupings, but the constants 
> inside a group.
> - add a comment to any constant.
> - create and assign a UUID to each constant to avoid any issue with 
> constant ID duplication.
> 
> there might be more that I do not remember off the top of my head.
> 
> Chip
> On Mon, 9 Dec 2019 15:20:05 +, Epperlein, Lutz (agendo) via 4D_Tech 
> wrote:
>> You have to use xliff and you can find an example here:
>> https://kb.4d.com/assetid=76583
>> 
>> Regards
>> Lutz
>> 
>> -Ursprüngliche Nachricht-
>> Von: 4D_Tech [mailto:4d_tech-boun...@lists.4d.com] Im Auftrag von 
>> Eric Naujock via 4D_Tech
>> Betreff: Constants in code.
>> 
>> Good morning,
>>  This seem pretty rudimentary, but I don’t seem find anything in the 
>> docs for this. 
>> 
>> Can you define your own Constants? I would like to define constants 
>> in my database to cover various groups for permissions. But what I am 
>> finding in the docs for v17r6 says they are listed in the constants 
>> window. But there does not seem to be anything that tells you how to 
>> create your own. Obviously there must be a way to do so since there 
>> are constants for plugins. 
>> **
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
>> **
> We have done so much, with so little, for so long;
> We are now qualified to anything with nothing 
>  - unknown
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: AW: Constants in code.

2019-12-09 Thread Chip Scheide via 4D_Tech
to expand
you can create 1 or more constants files in xlif format.
Inside each constants file you can create 'groups', logic assemblages 
of constants.
i.e. Web_Display, Interface_Colors, Listbox_Properties,  etc.
   
There is a tool in 4DPop (4Dpop constants editor) to help with this 
process.

The constant file(s) are then placed next to the structure in a folder 
titled "Constants". This folder may not already exist and you may have 
to create it. On a Mac you need to open the structure package (show 
package contents) to create/modify the Constants folder.

If you , or anyone else is interested, I have a version of 4DPop 
constants editor that I have modified to include the following 
enhancements (currently in v15 can/should be updatable to any newer 
version):
[send me an email making the request - and I'll send the modified 4DPop 
source code along.]

- open xlif files NOT in the current structure's path. i.e. open any 
xlif file, anywhere.
- drag n drop xlif files (as part of above).
- show all constants as a single list when there are groupings inside 
an xlif file, The constants are Not savable, including full sort order, 
in this 'mode'.
- able to re-load an xlif file, if modified by an outside program (i.e. 
text editor).
- sort (permanently if saved) not only the groupings, but the constants 
inside a group.
- add a comment to any constant.
- create and assign a UUID to each constant to avoid any issue with 
constant ID duplication.

there might be more that I do not remember off the top of my head.

Chip
On Mon, 9 Dec 2019 15:20:05 +, Epperlein, Lutz (agendo) via 4D_Tech 
wrote:
> You have to use xliff and you can find an example here:
> https://kb.4d.com/assetid=76583
> 
> Regards
> Lutz
> 
> -Ursprüngliche Nachricht-
> Von: 4D_Tech [mailto:4d_tech-boun...@lists.4d.com] Im Auftrag von 
> Eric Naujock via 4D_Tech
> Betreff: Constants in code.
> 
> Good morning,
>   This seem pretty rudimentary, but I don’t seem find anything in the 
> docs for this. 
> 
> Can you define your own Constants? I would like to define constants 
> in my database to cover various groups for permissions. But what I am 
> finding in the docs for v17r6 says they are listed in the constants 
> window. But there does not seem to be anything that tells you how to 
> create your own. Obviously there must be a way to do so since there 
> are constants for plugins. 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
We have done so much, with so little, for so long;
We are now qualified to anything with nothing 
  - unknown
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

AW: Constants in code.

2019-12-09 Thread Epperlein, Lutz (agendo) via 4D_Tech
You have to use xliff and you can find an example here:
https://kb.4d.com/assetid=76583

Regards
Lutz

-Ursprüngliche Nachricht-
Von: 4D_Tech [mailto:4d_tech-boun...@lists.4d.com] Im Auftrag von Eric Naujock 
via 4D_Tech
Betreff: Constants in code.

Good morning,
This seem pretty rudimentary, but I don’t seem find anything in the 
docs for this. 

Can you define your own Constants? I would like to define constants in my 
database to cover various groups for permissions. But what I am finding in the 
docs for v17r6 says they are listed in the constants window. But there does not 
seem to be anything that tells you how to create your own. Obviously there must 
be a way to do so since there are constants for plugins. 
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Constants in code.

2019-12-09 Thread Eric Naujock via 4D_Tech
Good morning,
This seem pretty rudimentary, but I don’t seem find anything in the 
docs for this. 

Can you define your own Constants? I would like to define constants in my 
database to cover various groups for permissions. But what I am finding in the 
docs for v17r6 says they are listed in the constants window. But there does not 
seem to be anything that tells you how to create your own. Obviously there must 
be a way to do so since there are constants for plugins. 
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Managing constants from code & retokenizing all methods

2017-01-29 Thread David Adams
I'm always the last to know. On the chance that I'm *not* the last to know,
Cannon Smith's UITimer module has a handy set of routines for managing 4D
constants through 4D code. From the read me:

  //Two other modules, OBJ and Constants, are included as support. The OBJ
module can be used to work
  //with C_Objects in 4D using dot syntax. The Constants module is used to
create contants
  //programatically. See their respective __Readme methods for more
information.

For any of his modules:

http://www.synergyfarmsolutions.com/styled/index.html

The UITimer module is in V16 but the code runs without revision in V15. For
some reason, you can't seem to drag-and-drop methods from V16 to V15. Is
that just me? OS X, 15.latest, 16.shipping.

I've wanted to convert over to code-generated constants for a long time but
have never gotten around to it. I think that Jim Dorrance has also posted
code to do this, but I don't have it in front of me. In any case, Cannon's
code works great and isn't particularly long.

Why not just use 4DPop? You can! Cannon's code won't automatically
translate an existing .xlf constants file to code, although it would be
cool if someone were to write that and share it. I didn't as it was super
easy to convert my existing constants on my current (smaller) project into
about a dozen individual constants files.

Background on constants:
* They really help avoid typos!

* They make the code easier to scan, at least for me.

* They are not used in compiled mode, so you can clear them out after
compilation or build. (Note to self: Add that to my post-build cleanup
routine.)

* All of the cool kids use them.

Personally, I'm happier controlling the definitions in code than through
the raw XML (ugh) or 4DPop, but that's a matter of taste. 4DPop has been
very helpful to me for constants for some time. In fact, it's the only
4DPop feature that I used. I like having everything in the code as it's
very easy to see and edit the labels and values - easier than in the XML
(ugh) or 4DPop, at least for me. Also, since I tend to move modules between
structures, it's nice that the constants come over automatically this way.

I'm adding in what amounts to a repost of some code by  Vincent de Lachaux
to retokenize all of the code in your database. Do you need this after
changing the constants. No, no you do not. But it can give you some peace
of mind. I run this code now and then to kick loose stray bugs the Compiler
is missing. Should you run code that rewrites every method and script in
your entire database without a backup? No you should not. Here's the code,
some bits left for manual revision in your particular system:

  // Method_RetokenizeAllCode

  // Adapted from a NUG thread in September of 2015.
  // From: Vincent de Lachaux<vincent.delach...@4d.com>
  // Date: Wednesday, September 23, 2015
  // Subject: Re-Tokenize Methods Procedurally
  // To: 4D iNug Technical<4d_tech@lists.4d.com>

C_BOOLEAN($1;$confirm_first)
$confirm_first:=True
If (Count parameters>=1)
$confirm_first:=$1
End if

C_BOOLEAN($continue)
$continue:=True

If (Is compiled mode )
  //Method_AlertIfRunningCompiled ("Method retokenization does not work in
compiled mode.")
$continue:=False
End if

OK:=0
If ($continue & $confirm_first)
C_TEXT($message)
$message:=""
$message:=$message+"Please make a backup of the structure if you haven't
already."+Char(Carriage return)+Char(Carriage return)
$message:=$message+"Close any methods currently open in the Design
environment before proceeding."+Char(Carriage return)+Char(Carriage return)
$message:=$message+"Retokenize all methods now?"

CONFIRM($message)
$continue:=OK=1
End if

If ($continue)
C_TEXT($icon_path)
C_LONGINT($progress_id)
C_BOOLEAN($enable_close)
$icon_path:=Resources_GetImageFilePath ("Validate_Code_Large.png")
$enable_close:=True
$progress_id:=Progress_Open ("Retokenizing all
code";$icon_path;$enable_close)

ARRAY TEXT($method_paths_at;0)
METHOD GET PATHS(Path all objects;$method_paths_at;*)

C_LONGINT($paths_count)
C_LONGINT($path_index)
$paths_count:=Size of array($method_paths_at)
For ($path_index;1;$paths_count)
C_TEXT($method_path)
$method_path:=$method_paths_at{$path_index}

Progress_Update ($progress_id;$method_path;$path_index/$paths_count)

C_TEXT($method_text)
METHOD GET CODE($method_path;$method_text;*)
METHOD SET CODE($method_path;$method_text;*)
End for

Progress_Close ($progress_id)
End if
**
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
**