Custom information in r-code files - OpenEdge Development - Products Enhancements - Progress Community

 OpenEdge Development

Custom information in r-code files

We need to get information from our r-codes, like the deployment version, to test this information during de product update. This process updates about 30 thousand programs each time it is run, and there is no way to open each .r to look for a string inside.

So, this idea sugests two implementations:

1. A possibility to input this custom string into the .r file. For example: proutil -C customstring "my string" programA.r programB.r programC.r programN.r

2. A possibility to easily read this custom string from the .r file with an ABL program. For example: rcode-info:file-name = "programA.r". display rcode-info:custom-string.

Comments
  • That's a nice idea. Maybe the custom string could also be set with ABL (e.g. COMPILE statement).

  • +1

  • This could also be achieved by a slightly enhanced version of reflection access to annotations (see community.progress.com/.../reflection_-_support_for_annotations), in the line of a Progress-defined enum like this:

    @RCODE( { Type="Serializable-UserDefinedInfo" } , [ FieldName1="value2" [, FieldName2="value2" [, ...] ] ] )

    Where   Serializable-UserDefinedInfo is a user defined type that must be serializable, with only primitive typed properties taking part in serialization, and can be retrieved as a Progress.Lang.Object using RCODE-INFO:CUSTOM-INFO.

    Example:

    /* Acme/Rcode/Info.cls */

    CLASS Acme.Rcode.Info SERIALIZABLE:

      DEFINE PUBLIC PROPERTY MajorVersion AS INT GET. SET.

      DEFINE PUBLIC PROPERTY MinorVersion AS INT GET. SET.

      DEFINE PUBLIC PROPERTY PatchLevel     AS INT GET. SET.

      DEFINE PUBLIC PROPERTY BuildNo           AS INT GET. SET.

      DEFINE PUBLIC PROPERTY Version AS STRING

           GET():

               RETURN SUBSTITUTE("&1.&2.&3 Build &4",

                                       MajorVersion,

                                       STRING(MinorVersion,"99"),

                                       STRING(PatchLevel,"999"),

                                       BuildNo).

          END GET.

      DEFINE PUBLIC PROPERTY CopyRight AS CHARACTER INIT "Acme Inc. (2016)" NO-UNDO GET.

      DEFINE PUBLIC PROPERTY Data AS CHARACTER GET. SET.

      @Hidden().

      DEFINE PUBLIC PROPERTY TechInfo AS CHARACTER GET. SET.

    END.

    /* Demo1.p */

    @RCODE(Type="Acme.Rcode.Info", MajorVersion="3", MinorVersion="1", Build="@Build").

    ....

    /* Demo2.p */

    @RCODE(Type="Acme.Rcode.Info", MajorVersion="3", MinorVersion="1", PatchLevel="3",

                                  TechInfo="SHA1,fa302427d99c59b01114ac23f44a44f1",

                                  Build="@Build", Data="Tickets 1231, 1292 and 1278").

    ....

    /* Test.p */

    iBuild  = getNextBuild().

    COMPILE Demo1.p BUILD=VALUE(iBuild) SAVE.

    COMPILE Demo2.p BUILD=VALUE(iBuild) SAVE.

    RCODE-INFO:FILE-NAME = "Demo1.p".

    MESSAGE CAST(RCODE-INFO:CUSTOM-INFO, Acme.Rcode.Info):Version .

    RCODE-INFO:FILE-NAME = "Demo2.p".

    MESSAGE CAST(RCODE-INFO:CUSTOM-INFO, Acme.Rcode.Info):Version .

    /* OUTPUT */

    3.01.000 Build 7214

    3.01.003 Build 7214

    An additional bonus would be if you could right-click the r-code in Windows Explorer and go to Properties to find an additional "RCode" tab listing the custom properties.

    Example:

    Browse to RCode Folder -> Right Click Demo2.r -> Properties

    Go to the RCode tab.

    See this:

    Major Version: 3

    Minor Version: 1

    Patch Level:    0

    Version:            3.01.003 Build 7214

    Copy Right:     Acme Inc. (2016)

    Data:                Tickets 1231, 1292 and 1278

  • Hi Simon

    I liked de possibilities of this example. It will not be usefull for me for version, because I need to put the information after compiling.

    Maybe I am to stupid for this, but I can't compile this code. Several errors. Is it missing some parts? Do you sugest any documentation with examples of classes to follow?

  • Hi Adriano

    The code will not compile, because it is pseudo code intended to demonstrate the idea of doing this with the compiler and annotations.

    As for adding the information after the fact, I would prefer to write the custom info class (Acme.Rcode.Info in the example) to a JSON file and then use something like:

    proutil -C insertRcodeCustomInfo  { list of programs or wildcards needed to detect rcode }

    This way, you can generate the data object with any tool that can maintain json, while maintaining the flexibility to address it as an object in ABL.

    Going one step further, you could the also do:

    proutil -C getRcodeCustomInfo programA.r [programA.json]

    This will enable non-ABL build tools to pick the info as an object and work with it.