Synergex / CodeGen

CodeGen is a tool that Synergy/DE developers can use to generate source code and other types of content based on the meta-data stored in a Synergy Repository.
Other
16 stars 8 forks source link

group as an array doesn't expand properly #24

Closed ameyer66 closed 3 years ago

ameyer66 commented 3 years ago

I apologize for the longwinded explanation but this is a bit of an edge case. If a repository structure has a group definition setup as an array that refers to another structure the actual record fields for the group don't get an array element suffix. Also if there are overlay fields in the middle of the group it causes the field order to be interspersed. The example here doesn't show that second effect. e.g.

STRUCTURE strPorder 
    pokey   ,d8 ; (1,8) 
    posup   ,d5 ; (9,13) 
...
    group poline    ,[10]a  ; (422,1341) 
        etl_potype  ,a1 ; (1,1) 
        etl_poprod  ,d6 ; (2,7) 
        etl_polosw  ,d1 ; (8,8) 
        etl_f2  ,a2 ; (9,10) 
        etl_pocat   ,a12    ; (11,22) 
        etl_poprix  ,d10    ; (23,32) 
        etl_web_poprix  ,d10.4 @strporder.poline.etl_poprix  ; (23,32) 
        etl_poqty   ,[3]d12 ; (33,68) 
        etl_web_poqty   ,[3]d12.4 @strporder.poline.etl_poqty    ; (33,68) 
        etl_poper   ,d1 ; (69,69) 
        etl_poglt   ,a1 ; (70,70) 
        etl_popmod  ,d1 ; (71,71) 
        etl_poplem  ,a1 ; (72,72) 
        etl_f11 ,a20    ; (73,92) 
        etl_poscom  ,a21 @strporder.poline.etl_poplem    ; (72,92) 
        etl_pocom   ,[2]a30 @strporder.poline.etl_poprod     ; (2,61) 
        etl_poitem  ,a2 @strporder.poline.etl_poprod     ; (2,3) 
        etl_pogl    ,d7 @strporder.poline.etl_poprod+2   ; (4,10) 
        etl_pomess  ,a5 @strporder.poline.etl_poprod     ; (2,6) 
    ENDGROUP
...
ENDSTRUCTURE

This codegen code:

<COUNTER_1_RESET>
<FIELD_LOOP>
  <IF CUSTOM_NOT_REPLICATOR_EXCLUDE>
    <COUNTER_1_INCREMENT>
    <IF COUNTER_1_EQ_1>
    if (ok && openAndBind)
    begin
        if (%ssc_bind(a_dbchn,c1<StructureName>,<REPLICATION_REMAINING_INCLUSIVE_MAX_250>,
    </IF COUNTER_1_EQ_1>
    <IF CUSTOM_DBL_TYPE>
        &    tmp<FieldSqlName><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
    <ELSE>
      <IF ALPHA>
        &    <structure_name>.<field_original_name_modified><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
      </IF ALPHA>
      <IF DECIMAL>
        &    <structure_name>.<field_original_name_modified><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
      </IF DECIMAL>
      <IF INTEGER>
        &    <structure_name>.<field_original_name_modified><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
      </IF INTEGER>
      <IF DATE>
        &    ^a(<structure_name>.<field_original_name_modified>)<IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
      </IF DATE>
      <IF TIME>
        &    tmp<FieldSqlName><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
      </IF TIME>
      <IF USER>
        <IF USERTIMESTAMP>
        &    tmp<FieldSqlName><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
        <ELSE>
          <IF DEFINED_ASA_TIREMAX>
        &    tmp<FieldSqlName><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
          <ELSE>
        &    <structure_name>.<field_original_name_modified><IF NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF NOMORE>
          </IF DEFINED_ASA_TIREMAX>
        </IF USERTIMESTAMP>
      </IF USER>
    </IF CUSTOM_DBL_TYPE>
    <IF COUNTER_1_EQ_250>
        begin
            ok = false
            sts = 0
            if (%ssc_getemsg(a_dbchn,errtxt,length,,dberror)==SSQL_FAILURE)
                errtxt="Failed to bind variables"
        end
    end
      <COUNTER_1_RESET>
    <ELSE>
      <IF NOMORE>
        begin
            ok = false
            sts = 0
            if (%ssc_getemsg(a_dbchn,errtxt,length,,dberror)==SSQL_FAILURE)
                errtxt="Failed to bind variables"
        end
    end
      </IF NOMORE>
    </IF COUNTER_1_EQ_250>
  </IF CUSTOM_NOT_REPLICATOR_EXCLUDE>
</FIELD_LOOP>

generates

    if (ok && openAndBind)
    begin
        if (%ssc_bind(a_dbchn,c1Porder,220,
        &    porder.pokey,
        &    porder.posup,
...
        &    porder.poline.etl_potype,
        &    porder.poline.etl_poprod,
        &    porder.poline.etl_polosw,
        &    porder.poline.etl_f2,
        &    porder.poline.etl_pocat,
        &    porder.poline.etl_poprix,
        &    porder.poline.etl_poqty[1],
        &    porder.poline.etl_poqty[2],
        &    porder.poline.etl_poqty[3],
        &    porder.poline.etl_poper,
        &    porder.poline.etl_poglt,
        &    porder.poline.etl_popmod,
        &    porder.poline.etl_poplem,
        &    porder.poline.etl_f11,
        &    porder.poline.etl_potype,
        &    porder.poline.etl_poprod,
        &    porder.poline.etl_polosw,
        &    porder.poline.etl_f2,
        &    porder.poline.etl_pocat,
        &    porder.poline.etl_poprix,
        &    porder.poline.etl_poqty[1],
        &    porder.poline.etl_poqty[2],
        &    porder.poline.etl_poqty[3],
        &    porder.poline.etl_poper,
        &    porder.poline.etl_poglt,
        &    porder.poline.etl_popmod,
        &    porder.poline.etl_poplem,
        &    porder.poline.etl_f11,
...

the porder.poline. field prefix should actually read as: porder.poline[x]. before the final field name where x is the array value, in this case 1 through 1 3_ST_POLIN.TXT 3_ST_PORDER.TXT SqlIO.tpl.txt 0.

ameyer66 commented 3 years ago

I did find however that using the tag: <structure_name>.<field_name> instead of the tag: <structure_name>.<field_original_name_modified> does make the field expand as desired.

SteveIves commented 3 years ago

Thanks for the additional information. I'm looking into it and will get back to you soon.

SteveIves commented 3 years ago

Fixed in release 5.7.6.