Conditionally Add #LOCALDATA

Hello,

Can you add #LOCALDATA with #IF in Templates?

I tried but keep on getting line errors;

#! ----------------------------------------------------------
#LOCALDATA
	#IF(%MNDocuVaultAddDebugCodeOptionLocals=1)
Loc:DocuVaultActiveHereYN           BYTE            !Loc:DocuVaultActiveHereYN
Loc:DocuVaultActiveUseDiskYN        BYTE            !Loc:DocuVaultActiveUseDiskYN
Loc:DocuVaultLegacyFolder           CSTRING(1024)   !Loc:DocuVaultLegacyFolder
Loc:ProgramArea                     STRING(30)      !Loc:ProgramArea
Loc:EngagementFilterYN              BYTE            !Loc:EngagementFilterYN
Loc:ReturnedS                       STRING(20)      !Loc:ReturnedS
Loc:ReturnedL                       LONG            !Loc:ReturnedL
Loc:ReturnedString                  STRING(2054)    !Loc:ReturnedString
	#ENDIF
	#IF(%MNDocuVaultAddDebugCodeOptionLocals=2)
Loc:DocuVaultActiveHereYN2           BYTE            !Loc:DocuVaultActiveHereYN2
Loc:DocuVaultActiveUseDiskYN2        BYTE            !Loc:DocuVaultActiveUseDiskYN2
Loc:DocuVaultLegacyFolder2           CSTRING(1024)   !Loc:DocuVaultLegacyFolder2
Loc:ProgramArea2                     STRING(30)      !Loc:ProgramArea2
Loc:EngagementFilterYN2              BYTE            !Loc:EngagementFilterYN2
Loc:ReturnedS2                       STRING(20)      !Loc:ReturnedS2
Loc:ReturnedL2                       LONG            !Loc:ReturnedL2
Loc:ReturnedString2                  STRING(2054)    !Loc:ReturnedString2
	#ENDIF
#ENDLOCALDATA
#! ----------------------------------------------------------

Nope! Instead, do it in an #AT(%DataSectionBeforeWindow).

If you are creating a #CONTROL template and you want to reference those in controls’ USE attribute, you can still do it. It will just seem like it’s disconnected, but it will compile just fine.

1 Like

I’ll link to Mike’s related recent post to check if a Variable is already defined in Local Data so you don’t add it in a Data Embed and create a duplicate error.

1 Like

Greetings -

Sometimes I use the construction:

  #IF(NOT VAREXISTS(%FamilyFound))
    #DECLARE(%FamilyFound)
  #ENDIF

Regards
Roberto Artigas

1 Like

That checks if the Template %Variable has been #DECLARE

The OP was talking about generated Clarion code variables in #LOCALDATA

Greetings - Correct!
Got my wires crossed, pressed return, and did not realize it was the wrong answer and should have been deleted.
My bad. My apologies for any inconvenience it might have caused.
Regards,
Roberto Artigas

Hi All,

How do you let it use the group only once and not multiple times when using the Extension template on more than one browse on the same screen?

Use %CustomFlags:

#IF(~INLIST(%Procedure &':MyFlag', %CustomFlags))
  #ADD(%CustomFlags, %Procedure &':MyFlag')
  #!... Your stuff
#ENDIF