FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Calculation with an array
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Calculation with an array
Posted: Mon Mar 28, 2022 07: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



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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Calculation with an array
Posted: Mon Mar 28, 2022 08:32 AM
hi Silvio,

try this
Code (fw): Select all Collapse
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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Calculation with an array
Posted: Mon Mar 28, 2022 09:25 AM

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
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Calculation with an array
Posted: Mon Mar 28, 2022 06: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



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
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Calculation with an array
Posted: Mon Mar 28, 2022 07: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

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Calculation with an array
Posted: Mon Mar 28, 2022 09: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 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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Calculation with an array
Posted: Tue Apr 12, 2022 11:24 AM
Jimmy wrote:hi Silvio,

try this
Code (fw): Select all Collapse
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


Because I have the totals on Vertical

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




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

Continue the discussion