nageswaragunupudi wrote:This logic gives the result as you expect:
- Code: Select all Expand view RUN
function ValSplit( nValue )
local nRest, aRet := {}
DEFAULT nValue := 391.65
nRest := nValue
AEval( {200,100,50,20,10,5,3,2,1,0.50,0.20,0.10,0.05}, ;
{ |n,i| If( n <= nRest, ( AAdd( aRet, { i, n } ), ;
nRest := ROUND( nRest - n, 2 ) ), nil ) } )
if nRest != 0.00
? "not possible. nRest =", nRest
else
XBROWSER aRet SETUP ( oBrw:cHeaders := { "COL", "EUROS" }, ;
oBrw:lFooter := .t., oBrw:aCols[ 2 ]:cEditPicture := "999.99", ;
oBrw:aCols[ 2 ]:nFooterType := AGGR_SUM, oBrw:MakeTotals() )
endif
return aRet
it's correct
I explain to you
In the procedure of the amounts the end user goes to select the amount of the bet (Lottery)
But when I close this dialog I'm going to save only the totals for each column
and I'm going to enter the totals in the first dialog
When I have to print the receipt I have another scheme
then I decompose the totals so you can know the columns and rows
that is, while in the insertion see figure 1 I have the prices vertically, in the printout of the receipt I have them horizontally
therefore, by breaking down the total prices for each group, I can print the pixel in the relative space
here I wanted to explain what I've been trying to do for days
If I try with
abolletta := {391.85,0,0,0,0,0,0,0,0,0,0,0,0}
aImports := Restore_Prices( abolletta)
Function Restore_Prices(aTotali)
local nRiga
local nColonna,
nNumero local nI
local nTotale
local aData:= {}
local aDataX:= {}
For ncolonna= 1 to 13
nTotale:= aTotali[ncolonna]
aData:= {}
aData:= ValSplit( nTotale ) For k= 1 to Len(adata)
nriga:=adata[k]
AaDd(aDataX,{nriga,nColonna} )
Next
Next
return aDataX
Now I have this
when I go to print i have error
// Imports
#define _MARGIN_TOP_IMPORTS 10.83
#define _MARGIN_LEFT_IMPORTS 2.25
#define _SQUARE_RAD_IMPORTS 0.9
#define _SQUARE_LEFT_IMPORTS 10.2
#define _SQUARE_SIZE_IMPORTS 0.44
#define _SQUARE_DIST_IMPORTS 0.13
#define _XSPACE_IMPORTS 0.57
#define _YSPACE_IMPORTS 0.7
- Code: Select all Expand view RUN
DEFINE BRUSH oBrush COLOR CLR_BLACK
PRINT oPrn NAME OemToAnsi( "Silvio Print" ) PREVIEW
DEFINE PEN oPen WIDTH 1 OF oPrn
PAGE // printing the circles form
Print_Imports( oPrn, oPen, aImports, oBrush )
ENDPAGE
ENDPRINT
Function Print_Imports( oPrn, oPen, aImports, oBrush )
LOCAL n, o
LOCAL nI
LOCAL nTop, nLeft, nBottom, nRight, aRect
LOCAL nVar := 1
LOCAL nRow, nCol
LOCAL nRadH := _SQUARE_RAD_IMPORTS * ( 10 * oPrn:nHorzRes() / oPRn:nHorzSize() ) / 10 // radius for round boxes in printer resolution horizontal
LOCAL nRadV := _SQUARE_RAD_IMPORTS * ( 10 * oPrn:nVertRes() / oPrn:nVertSize() ) / 10 // radius for round boxes in printer resolution vertical
local ncolonna, nRiga
for nI := 1 to len( aImports )
nColonna := aImports[ nI ][1]
nRiga := aImports[ nI ][2]
nRow := int( nRiga / 6 )
nCol := ( nColonna % 13 )
if nCol == 0
nCol := 13
else
++nRow
endif
nTop := _MARGIN_TOP_IMPORTS + .1 + ( --nRow * _YSPACE_IMPORTS )
nLeft := _MARGIN_LEFT_IMPORTS + .1 + ( --nCol * _XSPACE_IMPORTS )
nBottom := nTop - .1 + _SQUARE_SIZE_IMPORTS
nRight := nLeft - .1 + _SQUARE_SIZE_IMPORTS
oPrn:Cmtr2Pix( @nTop, @nLeft )
oPrn:Cmtr2Pix( @nBottom, @nRight )
aRect := { nTop, nLeft , nBottom , nRight }
oPrn:FillRect( aRect, oBrush )
next
return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com