I have to extract the 90 numbers, one at a time, the random ones. Whenever I extract a number, it is necessary to check if it already exists in a list array and in an atemp array.
I created the function OneNumb(oSay) but I saw that after about 63 numbers the procedure freezes and crashes, once I got to 82 numbers extracted and then the procedure crashed, I don't understand where the error is.
I add the get memo only for demo
- Code: Select all Expand view
#include "fivewin.ch"
static alista
Function test()
local oBtnNum,oBtnShow,oSay, cNumbers:= SPACE(400)
alista := {}
Define Dialog oDlg SIZE 500,300 PIXEL TRUEPIXEL RESIZABLE
@ 100,10 BUTTON oBtnNum PROMPT "+" of oDlg SIZE 40,22 ACTION OneNumb(oSay)
@ 100,10 BUTTON oBtnShow PROMPT "Show" of oDlg SIZE 80,22 ACTION ShowList(alista)
@ 10,10 GET oSay VAR cNumbers MEMO size 300,200 PIXEL of oDlg
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBtnNum:nLeft := oRect:nRight - 200
oBtnNum:nTop := oRect:nBottom - 25
oBtnShow:nLeft := oRect:nRight - 100
oBtnShow:nTop := oRect:nBottom - 25
oSay:nTop := oRect:nTop
oSay:nLeft := oRect:nLeft
oSay:nWidth := oRect:nRight - 200
oSay:nBottom := oRect:nBottom - 40
return nil
>
Activate dialog oDlg center ;
ON INIT ( EVAL( oDlg:bResized))
return nil
// take a number
Function OneNumb(oSay)
local n := 0, nLen := 1, nRandom, atemp := {}
local ctxt:=""
While n < nLen
nRandom := HB_RandomInt(90)
if AScan( alista, ltrim(str(nRandom)) ) == 0
if AScan( atemp, nRandom ) == 0
n += 1
aadd( atemp, nRandom )
endif
Endif
Enddo
//add number on alista
For n= 1 to Len(atemp)
idcheck:= atemp[n]
aadd(aLista,ltrim(str(idcheck)))
next
//only for demo
For n= 1 to Len(aLista)
ctxt+= aLista[n]+"-"
next
oSay:settext(ctxt)
return nil
//--------------------------------------------------------//
Function ShowList(alista)
xbrowser alista
return nil
//------------------------------------------------------//