Screen object sample code: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
m (typo)
 
(25 intermediate revisions by 8 users not shown)
Line 1: Line 1:
'''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 many of the Screen and ScreenField methods.
'''Screen class and Screenfield class example code'''  


  R SCRNSTBL 10000
The following program defines a screen application that displays and scrolls through a set of records. The records are initially obtained via the <var class="product">Fast/Unload User Language Interface</var> from a <var>Recordset</var> object to a <var>Stringlist</var>, though this is incidental to the main application details which feature multiple methods from the <var>[[Screen classes|Screen]]</var> and <var>[[Screen classes|ScreenField]]</var> classes.
b
 
%rs is object recordSet in file tomdb
<pre>
%ft is object fastUnloadTask
R SCRNSTBL 10000
%listi is object stringList
b
%listo is object stringList
%rs is object recordSet in file tomdb
%listr is object stringList
%ft is object fastUnloadTask
%rc float
%listi is object stringList
%i float
%listo is object stringList
%j float
%listr is object stringList
%title is string len 255
%rc float
%msg is string len 100
%i float
%j float
  * obtain the records that will be displayed
%title is string len 255
%msg is string len 100
find records to %rs
 
end find
  * obtain the records that will be displayed  
%listi = new
 
%listo = new
find records to %rs
%listr = new
end find
text to %listi
%listi = new
FOR EACH RECORD
%listo = new
  IF TOTAL PREMIUM EXISTS THEN
%listr = new
    PUT FULLNAME AS STRING(24)
text to %listi
    PUT STATE AS STRING(24)
FOR EACH RECORD
    PUT '$'
  IF TOTAL PREMIUM EXISTS THEN
    PUT TOTAL PREMIUM AS STRING
    PUT FULLNAME AS STRING(24)
    PUT '.00'
    PUT STATE AS STRING(24)
  END IF
    PUT '$'
  OUTPUT
    PUT TOTAL PREMIUM AS STRING
END FOR
    PUT '.00'
end text
  END IF
%rc = %rs:fastUnload(%listi, %listo, %listr, parameters='NEBUFF=2')
  OUTPUT
%sscr    is object screen
END FOR
%scrtop  is object screenField
end text
%scrfcmd is object screenField
%rc = %rs:fastUnload(%listi, %listo, %listr, parameters='NEBUFF=2')
%scrfmsg is object screenField
%sscr    is object screen
%scrfPF  is object screenField
%scrtop  is object screenField
%sscral  is arraylist of object screenField
%scrfcmd is object screenField
%sscr  = new
%scrfmsg is object screenField
%sscral = new
%scrfPF  is object screenField
%sscral  is arraylist of object screenField
%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, -
%scrtop = %sscr:addField(row=1, column=1, color=yellow, -
            width=%sscr:columns - 1, highlight=none)
          width=%sscr:columns - 1, highlight=none)
%scrtop:value = $center('August Listing', %sscr:columns - 1)
%scrtop:value = $center('August Listing', %sscr:columns - 1)
%scrfcmd = %sscr:addField(row=2, column=1, width=%sscr:columns - 1, color=yellow)
%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)
%scrfmsg = %sscr:addField(row=3, column=1, width=%sscr:columns - 1, color=yellow)
%scrfcmd:setCursor
%scrfcmd:setCursor
%scrfPF  = %sscr:addField(row=%sscr:rows, width=%sscr:columns - 2, column=1, 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
Line 63: 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:color = white
    %scrfmsg:highlight = none
    %scrfmsg:highlight = none
  end if
  end if
  jump to hl
  jump to hl
f1:
f1:
  %i = %i - (%sscral:count * 2)
  %i = %i - (%sscral:count * 2)
  if %i < 1 then
  if %i < 1 then
    %i = %listo:count - %sscral:count
    %i = %listo:count - %sscral:count
    if %i < 1 then
    if %i < 1 then
      %i = 1
      %i = 1
    end if
    end if
    %scrfmsg:value = 'Wrapped...'
    %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:color = white
     %scrfmsg:highlight = none
     %scrfmsg:highlight = none
  end if
  end if
  %j = 0
  %j = 0
  jump to hl
  jump to hl
f3:
f2:
  loop end
  if %i >= %listo:count then
hl:
    %i = 1
end repeat
    %scrfmsg:value = 'Wrapped...'
end  
    %scrfmsg:color = white
 
    %scrfmsg:highlight = none
 
  end if
==References==
  %j = 0
 
  jump to hl
The Janus SOAP manual in PDF format: http://sirius-software.com/maint/download/jansoapr.pdf
f3:
 
  loop end
The [[Screen class]] page on the Sirius Wiki.
hl:
end repeat
end  
</pre>


The [[Screenfield class]] page on the Sirius Wiki.
'''Note:''' The above sample shows many of the <var>Screen</var> and <var>Screenfield</var> class features, coded in a very procedural way.  You can also use the <var>Screen</var> class to create your own kind of screen in a fully object-oriented way.  See the [[Screen class using object-oriented syntax|example of a locally-written screen class]].


[[Screen Object Sample Code]]
==See also==
<ul>
<li>The [[Screen classes|"Screen classes"]] page


How to use [[Mod6 Screen|Model 6]], or [[Mod6 Screens|Dynamically Sized screens]] in Model 204.
<li>How to use [[Terminal MODEL 6 support|Model 6]], or dynamically sized screens, in <var class="product">Model 204</var>


[[Conventions and terminology]] used in Sirius Software technical documentation.
<li>[[Notation conventions for methods|Notation conventions]] used in <var class="product">Janus SOAP</var> documentation
</ul>

Latest revision as of 17:05, 20 January 2015

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 multiple methods from the Screen and ScreenField classes.

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 %rs
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 

Note: 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.

See also