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<[email protected]> // Date: Wednesday, September 23, 2015 // Subject: Re-Tokenize Methods Procedurally // To: 4D iNug Technical<[email protected]> 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:[email protected] **********************************************************************

