Procedure Test()
Local aResult := {}, aCombination := {}, aNumbers := {}, aTemp := {}
Local Lin := 0, Col := 0
aNumbers := {2 , 4 , 6 , 8 , 9 , 11 , 13 , 16 , 17 , 18 , 19 , 20 }
aAdd(aCombination,{01,02,03,04,05,06,07,08,09,11})
aAdd(aCombination,{01,02,03,04,05,06,07,08,09,12})
aAdd(aCombination,{01,02,03,04,05,06,07,08,10,11})
aAdd(aCombination,{01,02,03,04,05,06,07,09,10,12})
aAdd(aCombination,{01,02,03,04,05,08,09,10,11,12})
aAdd(aCombination,{01,02,03,04,06,07,09,10,11,12})
aAdd(aCombination,{01,02,03,04,05,06,08,10,11,12})
aAdd(aCombination,{01,02,04,05,07,08,09,10,11,12})
aAdd(aCombination,{01,03,04,06,07,08,09,10,11,12})
aAdd(aCombination,{01,04,05,06,07,08,09,10,11,12})
aAdd(aCombination,{02,03,05,06,07,08,09,10,11,12})
For Lin = 1 to 11
aTemp := Array(10)
For Col = 1 to 10
aTemp[Col] := aNumbers[aCombination[Lin,Col]]
end
aAdd(aResult,aTemp)
end
ApresentaMatriz(aResult,0)
Return
****************************************************************************
Procedure ApresentaMatriz(paMatriz,nZero,lTxt,cTxt)
****************************************************************************
*
* Apresentar uma matriz independente do numero de dimensoes
* Parametros: paMatriz
* Retorno:
*
* Autor: Samir
* 14/11/2008 - 17:05:55
*
****************************************************************************
local cMsg := "", nLen := 0, nDimensao := 0, m := 0, d := 0, lIgnoraZero := .F.
Default nZero := 3, lTxt := !Empty(cTxt), cTxt := "C:\matriz.txt"
If nZero = 0
lIgnoraZero := .T.
end
nLen := Len(paMatriz)
if ValType(paMatriz[1]) == "A"
nDimensao := Len(paMatriz[1])
else
nDimensao := 0
end
For m := 1 to nLen
If lIgnoraZero
cMsg += ""
else
cMsg += StrZero(m,nZero)+" - {"
end
if nDimensao != 0
For d := 1 to nDimensao
cMsg += DadosVar(paMatriz[m,d])
if d != nDimensao
cMsg += ", "
end
end
else
cMsg += DadosVar(paMatriz[m])
end
If lIgnoraZero
cMsg += ";"
else
cMsg += "};"
end
end
If !lTxt
MsgInfo(StrTran(cMsg,";",CRLF),"Informação")
else
If File(cTxt)
fErase(cTxt)
end
MemoWrit(cTxt,StrTran(cMsg,";",CRLF))
end
Return nil
/*------------------------------------------------------------------------*/
****************************************************************************
function DadosVar(xVar,lCompleto,cTitulo)
****************************************************************************
*
* Apresentar os dados de uma variável
* Parametros: xVar
* Retorno: Nenhum
*
* Autor: Samir
* 30/10/2008 - 10:32:55
*
****************************************************************************
local Result := "",nLen := 0, cTipo := "",cValor := ""
Default lCompleto := .F.
cTipo := ValType(xVar)
if cTipo = "C" .or. cTipo = "A"
nLen := Len(xVar)
else
nLen := 0
end
if cTipo == "C"
cValor := xVar
elseif cTipo == "N"
//cValor := Str(xVar,,,.T.)
cValor := AllTrim(Str(xVar))
elseif cTipo == "D"
cValor := DtoC(xVar)
elseif cTipo == "A"
ApresentaMatriz(xVar)
Return "Matriz"
elseif cTipo == "O"
cValor := "Objeto:" + xVar:ClassName()
elseif cTipo == "U"
cValor := "Nulo"
elseif cTipo == "L"
cValor := if(xVar,"True","False")
else
cValor := xVar
end
if lCompleto
//Result += "Tamanho: "+ Str(nLen,,,.T.) +";"
Result += "Tamanho: "+ AllTrim(Str(nLen)) +";"
Result += "Tipo: " + cTipo +";"
Result += "Valor: " + cValor +";"
MsgInfo(Result,cTitulo)
Return cValor
end
Return cValor
/*------------------------------------------------------------------------*/