Screen object sample code: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
(this is a TEST change... trying to work out the printing issues.)
Line 3: Line 3:
The following program defines a screen application that displays and scrolls through a set of records.  The records are initially obtained via the Fast/Unload User Language Interface from a RecordSet object to a StringList, though this is incidental to the main application details which feature the Screen and ScreenField methods.
The following program defines a screen application that displays and scrolls through a set of records.  The records are initially obtained via the Fast/Unload User Language Interface from a RecordSet object to a StringList, though this is incidental to the main application details which feature the Screen and ScreenField methods.


R SCRNSTBL 10000
<p class="pre">
b
R SCRNSTBL 10000
%rs is object recordSet in file tomdb
b
%ft is object fastUnloadTask
%rs is object recordSet in file tomdb
%listi is object stringList
%ft is object fastUnloadTask
%listo is object stringList
%listi is object stringList
%listr is object stringList
%listo is object stringList
%rc float
%listr is object stringList
%i float
%rc float
%j float
%i float
%title is string len 255
%j float
%msg is string len 100
%title is string len 255
%msg is string len 100
  * obtain the records that will be displayed
 
  * obtain the records that will be displayed  
find records to %rs
 
end find
find records to %r
%listi = new
end find
%listo = new
%listi = new
%listr = new
%listo = new
text to %listi
%listr = new
FOR EACH RECORD
text to %listi
  IF TOTAL PREMIUM EXISTS THEN
FOR EACH RECORD
    PUT FULLNAME AS STRING(24)
  IF TOTAL PREMIUM EXISTS THEN
    PUT STATE AS STRING(24)
    PUT FULLNAME AS STRING(24)
    PUT '$'
    PUT STATE AS STRING(24)
    PUT TOTAL PREMIUM AS STRING
    PUT '$'
    PUT '.00'
    PUT TOTAL PREMIUM AS STRING
  END IF
    PUT '.00'
  OUTPUT
  END IF
END FOR
  OUTPUT
end text
END FOR
%rc = %rs:fastUnload(%listi, %listo, %listr, parameters='NEBUFF=2')
end text
%sscr    is object screen
%rc = %rs:fastUnload(%listi, %listo, %listr, parameters='NEBUFF=2')
%scrtop  is object screenField
%sscr    is object screen
%scrfcmd is object screenField
%scrtop  is object screenField
%scrfmsg is object screenField
%scrfcmd is object screenField
%scrfPF  is object screenField
%scrfmsg is object screenField
%sscral  is arraylist of object screenField
%scrfPF  is object screenField
%sscr  = new
%sscral  is arraylist of object screenField
%sscral = new
%sscr  = new
%sscral = new
* separately format top three rows and the bottom row
 
* separately format top three rows and the bottom row
%scrtop = %sscr:addField(row=1, column=1, color=yellow, -
 
            width=%sscr:columns - 1, highlight=none)
%scrtop = %sscr:addField(row=1, column=1, color=yellow, -
%scrtop:value = $center('August Listing', %sscr:columns - 1)
          width=%sscr:columns - 1, highlight=none)
%scrfcmd = %sscr:addField(row=2, column=1, width=%sscr:columns - 1, color=yellow)
%scrtop:value = $center('August Listing', %sscr:columns - 1)
%scrfmsg = %sscr:addField(row=3, column=1, width=%sscr:columns - 1, color=yellow)
%scrfcmd = %sscr:addField(row=2, column=1, width=%sscr:columns - 1, color=yellow)
%scrfcmd:setCursor
%scrfmsg = %sscr:addField(row=3, column=1, width=%sscr:columns - 1, color=yellow)
%scrfPF  = %sscr:addField(row=%sscr:rows, width=%sscr:columns - 2, column=1, -
%scrfcmd:setCursor
            highlight=reverse, color=white)
%scrfPF  = %sscr:addField(row=%sscr:rows, width=%sscr:columns - 2, column=1, -
%title  = 'PF1=Backward PF2=Forward PF3=Quit'
          highlight=reverse, color=white)
%scrfPF:value = $center(%title, %sscr:columns - 2)
%title  = 'PF1=Backward PF2=Forward PF3=Quit'
%scrfPF:value = $center(%title, %sscr:columns - 2)
  * format the data display rows and store in arraylist
 
  * format the data display rows and store in arraylist  
 
  for %i from 1 to %sscr:rows - 5
  for %i from 1 to %sscr:rows - 5
   %sscral:add(%sscr:addField(row=%i + 3, column=1, width=%sscr:columns - 1, color=green))
   %sscral:add(%sscr:addField(row=%i + 3, column=1, width=%sscr:columns - 1, color=green))
Line 66: Line 67:
     %sscral(%i):color = turquoise
     %sscral(%i):color = turquoise
   end if
   end if
end for
end for
   
   
* populate the data display arraylist with unloaded data
* populate the data display arraylist with unloaded data
   
   
%i = 1
%i = 1
%j = 0
%j = 0
repeat forever
repeat forever
  for %i from %i to %listo:count
  for %i from %i to %listo:count
    %j = %j + 1
    %j = %j + 1
    if %j > %sscral:count then
    if %j > %sscral:count then
      loop end
      loop end
    end if
    end if
    %sscral(%j):value = $lowcase(%listo(%i))
    %sscral(%j):value = $lowcase(%listo(%i))
  end for
  end for
    
    
  for %j from %j to %sscral:count
  for %j from %j to %sscral:count
    %sscral(%j):value = ''
    %sscral(%j):value = ''
  end for
  end for
   
   
* display screen and process user response
* display screen and process user response
   
   
  %sscr:read
  %sscr:read
  %scrfmsg:value = ''
  %scrfmsg:value = ''
  jump to (f1, f2, f3) %sscr:actionKey:toNumber
  jump to (f1, f2, f3) %sscr:actionKey:toNumber
  if %sscr:actionKey:toNumber then
  if %sscr:actionKey:toNumber then
    %scrfmsg:value = 'Only PF1-PF3 are valid keys'
    %scrfmsg:value = 'Only PF1-PF3 are valid keys'
    %scrfmsg:color = red
    %scrfmsg:color = red
    %scrfmsg:highlight = reverse
    %scrfmsg:highlight = reverse
  else
  else
    %scrfmsg:value = 'Enter key pressed'
    %scrfmsg:value = 'Enter key pressed'
    %scrfmsg:color = white
    %scrfmsg:highlight = none
  end if
  jump to hl
f1:
  %i = %i - (%sscral:count * 2)
  if %i < 1 then
    %i = %listo:count - %sscral:count
    if %i < 1 then
      %i = 1
    end if
    %scrfmsg:value = 'Wrapped...'
     %scrfmsg:color = white
     %scrfmsg:color = white
     %scrfmsg:highlight = none
     %scrfmsg:highlight = none
  end if
  end if
  jump to hl
  %j = 0
f1:
  jump to hl
  %i = %i - (%sscral:count * 2)
f2:
  if %i < 1 then
  if %i >= %listo:count then
    %i = %listo:count - %sscral:count
    %i = 1
    if %i < 1 then
    %scrfmsg:value = 'Wrapped...'
      %i = 1
    %scrfmsg:color = white
    end if
    %scrfmsg:highlight = none
    %scrfmsg:value = 'Wrapped...'
  end if
    %scrfmsg:color = white
  %j = 0
    %scrfmsg:highlight = none
  jump to hl
  end if
f3:
  %j = 0
  loop end
  jump to hl
hl:
f2:
end repeat
  if %i >= %listo:count then
end  
    %i = 1
</p>
    %scrfmsg:value = 'Wrapped...'
    %scrfmsg:color = white
    %scrfmsg:highlight = none
  end if
  %j = 0
  jump to hl
f3:
  loop end
hl:
end repeat
end  


The above sample shows many of the Screen and Screenfield class features, coded in a very procedural way.  You can also use the screen class to create your own kind of screen in a fully object-oriented way.  See the [[Screen class using OO Syntax|example of a locally-written screen class]].
The above sample shows many of the Screen and Screenfield class features, coded in a very procedural way.  You can also use the screen class to create your own kind of screen in a fully object-oriented way.  See the [[Screen class using OO Syntax|example of a locally-written screen class]].

Revision as of 18:30, 16 September 2010

Screen class and Screenfield class example code

The following program defines a screen application that displays and scrolls through a set of records. The records are initially obtained via the Fast/Unload User Language Interface from a RecordSet object to a StringList, though this is incidental to the main application details which feature the Screen and ScreenField methods.

R SCRNSTBL 10000 b %rs is object recordSet in file tomdb %ft is object fastUnloadTask %listi is object stringList %listo is object stringList %listr is object stringList %rc float %i float %j float %title is string len 255 %msg is string len 100 * obtain the records that will be displayed find records to %r end find %listi = new %listo = new %listr = new text to %listi FOR EACH RECORD IF TOTAL PREMIUM EXISTS THEN PUT FULLNAME AS STRING(24) PUT STATE AS STRING(24) PUT '$' PUT TOTAL PREMIUM AS STRING PUT '.00' END IF OUTPUT END FOR end text %rc = %rs:fastUnload(%listi, %listo, %listr, parameters='NEBUFF=2') %sscr is object screen %scrtop is object screenField %scrfcmd is object screenField %scrfmsg is object screenField %scrfPF is object screenField %sscral is arraylist of object screenField %sscr = new %sscral = new

  • separately format top three rows and the bottom row

%scrtop = %sscr:addField(row=1, column=1, color=yellow, - width=%sscr:columns - 1, highlight=none) %scrtop:value = $center('August Listing', %sscr:columns - 1) %scrfcmd = %sscr:addField(row=2, column=1, width=%sscr:columns - 1, color=yellow) %scrfmsg = %sscr:addField(row=3, column=1, width=%sscr:columns - 1, color=yellow) %scrfcmd:setCursor %scrfPF = %sscr:addField(row=%sscr:rows, width=%sscr:columns - 2, column=1, - highlight=reverse, color=white) %title = 'PF1=Backward PF2=Forward PF3=Quit' %scrfPF:value = $center(%title, %sscr:columns - 2) * format the data display rows and store in arraylist for %i from 1 to %sscr:rows - 5 %sscral:add(%sscr:addField(row=%i + 3, column=1, width=%sscr:columns - 1, color=green)) if $mod(%i - 1, 5) = 0 then %sscral(%i):highlight = underline %sscral(%i):color = turquoise end if end for

  • populate the data display arraylist with unloaded data

%i = 1 %j = 0 repeat forever for %i from %i to %listo:count %j = %j + 1 if %j > %sscral:count then loop end end if %sscral(%j):value = $lowcase(%listo(%i)) end for for %j from %j to %sscral:count %sscral(%j):value = end for

  • display screen and process user response

%sscr:read %scrfmsg:value = jump to (f1, f2, f3) %sscr:actionKey:toNumber if %sscr:actionKey:toNumber then %scrfmsg:value = 'Only PF1-PF3 are valid keys' %scrfmsg:color = red %scrfmsg:highlight = reverse else %scrfmsg:value = 'Enter key pressed' %scrfmsg:color = white %scrfmsg:highlight = none end if jump to hl f1: %i = %i - (%sscral:count * 2) if %i < 1 then %i = %listo:count - %sscral:count if %i < 1 then %i = 1 end if %scrfmsg:value = 'Wrapped...' %scrfmsg:color = white %scrfmsg:highlight = none end if %j = 0 jump to hl f2: if %i >= %listo:count then %i = 1 %scrfmsg:value = 'Wrapped...' %scrfmsg:color = white %scrfmsg:highlight = none end if %j = 0 jump to hl f3: loop end hl: end repeat end

The above sample shows many of the Screen and Screenfield class features, coded in a very procedural way. You can also use the screen class to create your own kind of screen in a fully object-oriented way. See the example of a locally-written screen class.


References

The Janus SOAP manual in PDF format: http://sirius-software.com/maint/download/jansoapr.pdf

The Screen class page on the Sirius Wiki.

The Screenfield class page on the Sirius Wiki.

Screen Object Sample Code

How to use Model 6, or Dynamically Sized screens in Model 204.

Conventions and terminology used in Sirius Software technical documentation.