! *viewer/paperbins.pvc - Paper Source Bin Object
! By Gord Davey
! (c) Copyright 2004-2005 Sage Software Canada Ltd.
! Version:
! Source Code File: $RCSfile: paperbins.pvs,v $   Version: $Revision: 1.5 $
!      Last Edited: $Date: 2005/10/14 15:31:18 $   Author: $Author: gordd $
!
! This object is used to Validate Paper Bins (Paper Sources) and
! can return the names of the bins given their number.
!
def class "*viewer/paperbins" unique

    property Version$ = mid(mid("$Revision: 1.5 $",12), 1, len(mid("$Revision: 1.5 $",12)) - 2)

    property DMBIN_UPPER         = 1
    property DMBIN_ONLYONE       = 1
    property DMBIN_LOWER         = 2
    property DMBIN_MIDDLE        = 3
    property DMBIN_MANUAL        = 4
    property DMBIN_ENVELOPE      = 5
    property DMBIN_ENVMANUAL     = 6
    property DMBIN_AUTO          = 7
    property DMBIN_TRACTOR       = 8
    property DMBIN_SMALLFMT      = 9
    property DMBIN_LARGEFMT      = 10
    property DMBIN_LARGECAPACITY = 11
    property DMBIN_CASSETTE      = 14
    property DMBIN_FORMSOURCE    = 15
    property DMBIN_LAST          = DMBIN_FORMSOURCE
    property DMBIN_FIRST         = DMBIN_UPPER
    property DMBIN_USER          = 256

    ! Returns 1=Bin Exists, 0=No Such Bin
    function GetPaperBin(BinNumber%)                       GetBinProperties

    ! Returns 1=Bin Exists, 0=No Such Bin, and BinName$
    function GetPaperBinProperties(BinNumber%, BinName$)   GetBinProperties

    ! Returns 1=Success, 0=No Names, and a SEP delim list of Bin names (not bin 256)
    function GetPaperBinNames(BinNames$)                   GetBinNames

fnend
!
!
GetBinProperties:
    enter (Value%), BinName$, err=*next

    switch Value%
        case 1
            x$ = msg("DMBIN_UPPER")
            BinName$ = tbl(x$ <> "DMBIN_UPPER:", x$, "Upper Tray")
            break

        case 2
            x$ = msg("DMBIN_LOWER")
            BinName$ = tbl(x$ <> "DMBIN_LOWER:", x$, "Lower Tray")
            break

        case 3
            x$ = msg("DMBIN_MIDDLE")
            BinName$ = tbl(x$ <> "DMBIN_MIDDLE:", x$, "Middle Tray")
            break

        case 4
            x$ = msg("DMBIN_MANUAL")
            BinName$ = tbl(x$ <> "DMBIN_MANUAL:", x$, "Manual Feed Tray")
            break

        case 5
            x$ = msg("DMBIN_ENVELOPE")
            BinName$ = tbl(x$ <> "DMBIN_ENVELOPE:", x$, "Envelope Tray")
            break

        case 6
            x$ = msg("DMBIN_ENVMANUAL")
            BinName$ = tbl(x$ <> "DMBIN_ENVMANUAL:", x$, "Envelope Manual Feed Tray")
            break

        case 7
            x$ = msg("DMBIN_AUTO")
            BinName$ = tbl(x$ <> "DMBIN_AUTO:", x$, "Auto-Select Tray")
            break

        case 8
            x$ = msg("DMBIN_TRACTOR")
            BinName$ = tbl(x$ <> "DMBIN_TRACTOR:", x$, "Tractor Feed")
            break

        case 9
            x$ = msg("DMBIN_SMALLFMT")
            BinName$ = tbl(x$ <> "DMBIN_SMALLFMT:", x$, "Small Format Bin")
            break

        case 10
            x$ = msg("DMBIN_LARGEFMT")
            BinName$ = tbl(x$ <> "DMBIN_LARGEFMT:", x$, "Large Format Bin")
            break

        case 11
            x$ = msg("DMBIN_LARGECAPACITY")
            BinName$ = tbl(x$ <> "DMBIN_LARGECAPACITY:", x$, "Large Capacity Bin")
            break

        case 14
            x$ = msg("DMBIN_CASSETTE")
            BinName$ = tbl(x$ <> "DMBIN_CASSETTE:", x$, "Cassette Tray")
            break

        case 15
            x$ = msg("DMBIN_FORMSOURCE")
            BinName$ = tbl(x$ <> "DMBIN_FORMSOURCE:", x$, "To Form Source")
            break

        case 256
            x$ = msg("DMBIN_USER")
            BinName$ = tbl(x$ <> "DMBIN_USER:", x$, "Custom Tray")
            break

        default
            BinName$ = "<Error>"
            break
    esac

    if BinName$ = "<Error>" \
        then BinName$ = ""; return 0 \
        else return 1
!
!
GetBinNames:
    enter BinName$

    last = _obj'DMBIN_LAST, \
    BinName$ = ""

    for x = 1 to last;
        r = _obj'GetPaperBinProperties(x, n$);
        if r and n$ > "" \
            then BinName$ += n$ + sep \
        fi;
    next x

    if len(BinName$) \
        then return 1 \
        else return 0
