Calculation with an array

Post Reply
User avatar
Silvio.Falconi
Posts: 7166
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 2 times

Calculation with an array

Post by Silvio.Falconi »

Having a total example € 3.50 I have to break it so you can turn on a series of buttons that have a different price

I Explain You

I have an array aImports:={200,100,50,20,10,5,3,2,1,0.50,0.20,0.10,0.05}

every record relates to a button

Image

if I have a total = 3.50 I have to wiper to turn on the buttons that 3.50 do

in this case aImports[7] and aImports[10]

How I can do to calculate it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 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
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: Calculation with an array

Post by Jimmy »

hi Silvio,

try this

Code: Select all | Expand

PROCEDURE BinCalc(nValue)
LOCAL aImports:={200,100,50,20,10,5,3,2,1,0.50,0.20,0.10,0.05}
LOCAL nPosi := 0
LOCAL nRest := nValue
LOCAL aRet   := {}

   DO WHILE .T.
?     nPosi := ASCAN(aImports,{|e| e <= nRest})
      IF nPosi > 0
         AADD(aRet,nPosi)
         nRest -= aImports[nPosi]
      ELSE
         EXIT
      ENDIF
   ENDDO
RETURN aRet
greeting,
Jimmy
User avatar
Silvio.Falconi
Posts: 7166
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 2 times

Re: Calculation with an array

Post by Silvio.Falconi »

THAKSSSS
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 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
User avatar
FranciscoA
Posts: 2164
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Calculation with an array

Post by FranciscoA »

Silvio.Falconi wrote:Having a total example € 3.50 I have to break it so you can turn on a series of buttons that have a different price

I Explain You

I have an array aImports:={200,100,50,20,10,5,3,2,1,0.50,0.20,0.10,0.05}

every record relates to a button

Image

if I have a total = 3.50 I have to wiper to turn on the buttons that 3.50 do

in this case aImports[7] and aImports[10]

How I can do to calculate it ?


only for curiosity:
would you ever use a value of 3.90, 3.80, or 3.59 (among others)?
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
Otto
Posts: 6414
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 30 times
Been thanked: 2 times
Contact:

Re: Calculation with an array

Post by Otto »

Silvio, I know you don't like it. But this programme would be a good sample to start with mod harbour.
Many greetings
Otto
https://www.facebook.com/groups/modharbour.club/?multi_permalinks=1090583058162587&notif_id=1648482958093104

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Silvio.Falconi
Posts: 7166
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 2 times

Re: Calculation with an array

Post by Silvio.Falconi »

Unfortunately, someone died during the pandemic.


Now it happens that this someone had created a software for the bookstores and therefore it is not possible to update it.

I'm just trying to see if I can redo the program.

For many years I have been doing something but only classic statistics those you find on all websites, forecasts and combinatorial calculations and for about a month I have been implementing some systems of my own creation for the drafting of lottery games.


What you see (the prices) is a small part of the whole I'm putting up, unfortunately I don't have much time, I have a job at school, and serious problems with my 90-year-old mother who causes me several problems so the creation of the software goes very slowly.

Otto it is not true that I don't like it, it just annoys me that you always take my ideas to create tests with this mod_harbour that I am convinced that it will end with all the projects that have done and have not finished.

But you dear Otto you do not know this, you are young in fwh and you think you are all "roses and flowers"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 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
User avatar
Silvio.Falconi
Posts: 7166
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 2 times

Re: Calculation with an array

Post by Silvio.Falconi »

Jimmy wrote:hi Silvio,

try this

Code: Select all | Expand

PROCEDURE BinCalc(nValue)
LOCAL aImports:={200,100,50,20,10,5,3,2,1,0.50,0.20,0.10,0.05}
LOCAL nPosi := 0
LOCAL nRest := nValue
LOCAL aRet   := {}

   DO WHILE .T.
?     nPosi := ASCAN(aImports,{|e| e <= nRest})
      IF nPosi > 0
         AADD(aRet,nPosi)
         nRest -= aImports[nPosi]
      ELSE
         EXIT
      ENDIF
   ENDDO
RETURN aRet



Jimmy
this run good on Dialog
Image

Because I have the totals on Vertical

Now the problem I have on Print the ticket because I have it on Horizontal

Image


and I not Know how make it

the column are 11
the rows are 8
Pls Help
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 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
Post Reply