Calculation with an array

Calculation with an array

Postby Silvio.Falconi » Mon Mar 28, 2022 7:54 am

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 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculation with an array

Postby Jimmy » Mon Mar 28, 2022 8:32 am

hi Silvio,

try this
Code: Select all  Expand view
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
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Calculation with an array

Postby Silvio.Falconi » Mon Mar 28, 2022 9:25 am

THAKSSSS
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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculation with an array

Postby FranciscoA » Mon Mar 28, 2022 6:46 pm

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
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Calculation with an array

Postby Otto » Mon Mar 28, 2022 7:40 pm

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
Otto
 
Posts: 6310
Joined: Fri Oct 07, 2005 7:07 pm

Re: Calculation with an array

Postby Silvio.Falconi » Mon Mar 28, 2022 9:29 pm

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 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculation with an array

Postby Silvio.Falconi » Tue Apr 12, 2022 11:24 am

Jimmy wrote:hi Silvio,

try this
Code: Select all  Expand view
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 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], SantaCroya and 55 guests