*! version 0.1.1 2011-04-04 change nane to _clct_ListMatrix
* version 0.1.0 2011-02-02
* Based on snag version 0.0.8 2010-09-26

*  - scott long and jd wolfe: collecting statistics

//  _clct_ListMatrix: list collected matrix.

program _clct_ListMatrix, sclass

    syntax , matprint(string) matname(string) ///
            [ preview list transpose listnew format(string) ///
            matrownum(string) title(string) ]
    version 10.1

local stataVrunning = c(stata_version)


    tempname tempmat
    * build title
    local Ltitle ""
    if "`preview'"=="preview" local Ltitle "preview of "
    if "`listnew'"=="listnew" local Ltitle "`Ltitle'changes to "
    if "`transpose'"=="transpose" local Ltitle "`Ltitle'transposed "
    local Ltitle "`Ltitle'`matname': `title'"

    * list entire matrix
    if "`list'"=="list" {
        if "`transpose'"=="transpose" {
            version `stataVrunning' : matrix `tempmat' = `matprint''
        }
        else {
            version `stataVrunning' : matrix `tempmat' = `matprint'
        }
    }

    * list current row
    if "`listnew'"=="listnew" {
      version `stataVrunning' : matrix `tempmat' = `matprint'[`matrownum',1...]
    }

    * print matrix
    di _newline "`Ltitle'"
    version `stataVrunning' : matrix list `matprint', ///
        format(`format') nohalf noheader
end
exit