Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Reference Index > Using PAGEMODE

Example: Checking Column Width

Scroll Prev Top Next More

The command lines below are used to display data in three columns evenly spaced across the page with a four space margin on the left side of the page. You determine in your program whether the columns go across the page and then down, or first down the page and then across.

 

You should set up the column positions at the beginning of your program rather than automatically incrementing the column display variable by a certain amount and checking against the WIDTH setting.

 

SET VARIABLE vColumn1 = 5

SET VARIABLE vColumn2 = 30

SET VARIABLE vColumn3 = 55

...

WRITE .vName AT .vRow, .vColumn1

WRITE .vName AT .vRow, .vColumn2

WRITE .vName AT .vRow, .vColumn3

 

The number of columns can be dynamically calculated based on the maximum length of values to display for a group of data. Use the SLEN and MAX functions to find the maximum data length for the group of data.

 

-- compute the maximum text length

 

SELECT MAX(SLEN(title)) INTO vLen +

 FROM books WHERE lstnm = .vLName

 

-- set the number of columns based

-- on the maximum text length

 

IF vLen <= 25 THEN

 SET VAR vNumCols = 3

 SET VAR vColumn1 = 5

 SET VAR vColumn2 = 30

 SET VAR vColumn3 = 55

ELSE

 IF vLen <= 50 THEN

   SET VAR vNumCols = 2

   SET VAR vColumn1 = 5

   SET VAR vColumn2 = 40

 ELSE

   SET VAR vNumCols = 1

   SET VAR vColumn1 = 5

 ENDIF

ENDIF

 

Set SELMARGIN to specify the beginning column for SELECT command output. SELECT and SELMARGIN can be used with WHERE CURRENT OF CURSOR to display a row of data starting at any column position.