All:

Following is a simple routine to take a four-digit GL Code (ex. 7512) and
extract GL nesting values into four target variables.

The target variable name vCOAx is a concatenation, allowing incrementing
with each loop.

Watch variables prove that the ampersanded variable assignment works:

vGLCode = 7512
vCOA1 = 7000
vCOA2 = 7500
vCOA3 = 7510
vCOA4 = 7512

But. The 'WRITE' statement, being a testing substitute for saving off the
values, write out the literal NAME of the variable, not its VALUE:

vCOA1
vCOA2
vCOA3
vCOA4

What am I missing that would write out the variable values, not the variable
names?

Thanks much

Bruce

--file: cmd_glcode_breakdown.rmd
--rbse: global
--auth: bachitiea
--crea: 2013-0623

--Environment
SET TRACE ON
CLEAR VAR v%
--CLS

--Variables
SET VAR vGLCode TEXT = NULL
SET VAR vRoundingLevel INTEGER = -3
SET VAR vGLSegment TEXT = NULL
SET VAR vGLSegmentBody TEXT = 'vCOA'
SET VAR vGLSegmentLevel INTEGER = 1

--Value Entry
DIALOG 'Enter a four-digit GL Code' vGLCode =4 vendkey 1 +
  CAPTION 'Test Entry'

SET VAR vGLCode INTEGER

LABEL LoopEnter
--Indent

  SET VAR vGLSegment = (.vGLSegmentBody + (CTXT(.vGLSegmentLevel)))
  SET VAR &vGLSegment INTEGER = (RNDDOWN(.vGLCode,.vRoundingLevel))
  IF &vGLSegment = .vGLCode THEN
    WRITE .vGLSegment
    GOTO LoopExit
  ELSE
    WRITE .vGLSegment
    SET VAR vGLSegmentLevel = (.vGLSegmentLevel + 1)
    SET VAR vRoundingLevel = (.vRoundingLevel + 1)
    GOTO LoopEnter
  ENDIF

--Outdent
LABEL LoopExit

LABEL Exit
--CLEAR VAR v%
RETURN

Reply via email to