Tony:

 

Thank you very much. 

 

At first glance, the 'SET VAR &vGLSegment...' seemed counter-intuitive to
me, too.

 

But I wanted to run a loop and generate a set of incrementally NAMED
variables and assign to them incremented VALUES.

 

As the loop spins:

 

1.      Create an incrementing variable name:

Construct an incrementing TEXT variable NAME from two name-component
variables:

 

SET VAR vGLSegment = (.vGLSegmentBody + (CTXT(.vGLSegmentLevel)))

 

2.      Assign incrementing values to the incrementing-name variables:

 

SET VAR &vGLSegment INTEGER = (RNDDOWN(.vGLCode,.vRoundingLevel))

 

In this construct, 'SET VAR &vGLSegment' resolves internally to 'SET VAR
vCOAx' as intended, because:

 

"The "&" in front of the variable name tells R:BASE that the variable
contains part of the command, not a value, and the contents of the variable
are used when parsing the command."

 

Dennis provided the missing step, which was to capture the variable NAME
into a construct which allows the use of its VALUE:

 

SET VAR vCOAValue TEXT  = ('.' + .vGLSegment)

WRITE &vCOAValue

 

DEFINITELY one for the toolbox.

 

Thanks again,

 

Bruce Chitiea

SafeSectors, Inc.

eCondoMetrics

 

From: [email protected] [mailto:[email protected]] On Behalf Of Tony IJntema
Sent: Monday, June 24, 2013 12:31 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - RE: Routine writes out variable names, not values.

 

At least the statement :

 

SET VAR &vGLSegment INTEGER

 

is not correct

 

Don't use the . and & in combination with SET VAR 

Normally the dot and ampersand are not used at the left site of of an
equation

 

  IF &vGLSegment = .vGLCode THEN

Should be:

 

IF vGLSegment = .vGLCode THEN

 

Razzak did write an interesting article about it a couple of weeks ago.

 

Tony

 

 

 

 

 

 

From: [email protected] <mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Bruce A. Chitiea
Sent: maandag 24 juni 2013 1:42
To: RBASE-L Mailing List
Subject: [RBASE-L] - Routine writes out variable names, not values.

 

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