Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
QB64 Discussion / Re: What the heck happened to MEM.TYPEs??
« Last post by SMcNeill on Yesterday at 05:59:44 PM »
Wiki updated to reflect the correct values for mem.TYPE.  :)
22
QB64 Discussion / Re: Question about RND e RANDOMIZE TIMER
« Last post by bplus on Yesterday at 05:32:57 PM »
Without RANDOMIZE the RND sequence is always the same, handy for debugging programs using RND.

RANDOMIZE seed
just gives you a different random number sequence, depending on what seed you provide.

The sequences are always the same according to seed. TIMER is nice for seed because you get a different seed every second (or less?). Update: Help says, "every run".

Update: Oh forgot about USING
Code: QB64: [Select]
  1. seed1 = 10: seed2 = 133
  2.  
  3.     RANDOMIZE USING seed1
  4.     FOR i = 1 TO 20
  5.         flipB% = INT(RND * 4) + 1
  6.         PRINT flipB%;
  7.     NEXT
  8.     PRINT: PRINT
  9.     RANDOMIZE USING seed2
  10.     FOR i = 1 TO 20
  11.         flipB% = INT(RND * 4) + 1
  12.         PRINT flipB%;
  13.     NEXT
  14.     PRINT: PRINT
  15.     PRINT "Press any... to repeat, esc to quit "
  16.     SLEEP
  17.  
23
QB64 Discussion / Re: What the heck happened to MEM.TYPEs??
« Last post by FellippeHeitor on Yesterday at 05:28:34 PM »
Just sent you a private message here on the forum with a new user name and password.
24
QB64 Discussion / Re: Difference in CPU Usage in Hardware vs Software images
« Last post by bartok on Yesterday at 05:17:10 PM »
ok, I got it.
25
QB64 Discussion / Re: Difference in CPU Usage in Hardware vs Software images
« Last post by SMcNeill on Yesterday at 05:10:45 PM »
conceptually, what is the difference between hardware and software images?

Hardware images process on your GPU.  Software images on your CPU.
26
QB64 Discussion / Re: Difference in CPU Usage in Hardware vs Software images
« Last post by bartok on Yesterday at 05:09:13 PM »
conceptually, what is the difference between hardware and software images?
27
QB64 Discussion / Re: What the heck happened to MEM.TYPEs??
« Last post by SMcNeill on Yesterday at 04:56:01 PM »
@SMcNeill I've just reset your wiki credentials in case you'd lost them. Please check the email you have associated with your forum account.

For whatever reason, I’m not getting that email.  Other folks send stuff to me successfully via the forums mail/messages, but the wiki reset is getting lost somewhere along the way.  :(
28
QB64 Discussion / Question about RND e RANDOMIZE TIMER
« Last post by bartok on Yesterday at 04:47:19 PM »
I have not understood at all the command RND.
As an exemple:
flipB% = INT(RND * 4) + 1
PRINT flipB%

generates and prints a ramdom number between 1 and 4, but it is always 3. So: why 3, and, if it is a random number, why always only 3?

If I want a true random numer, I have to tape:
RANDOMIZE TIMER
flipB% = INT(RND * 4) + 1
PRINT flipB%

in this case, every time I run the program, I can actually have a number between 1 and 4.

so, if RND alone don't generate a random numer, what is its utility without RANDOMIZE TIMER? why RND don't generate itself a random number? And what is the use of RANDOMIZE TIMER without RND?
29
QB64 Discussion / Re: graphs with QB64 and how to scroll the screen.
« Last post by bartok on Yesterday at 04:38:38 PM »
Thanks Pete, very interesting.

your double DO is the solution. I solved as you can see below.

As you can see, I made some tries with the "flag" and I  admit that I haven't fully understood it. Finally, I put a simply EXIT DO in lines 109, 106 and 112. So, the program terminates in the main code. Without the double DO, the EXIT put in the main code where or the program finished, or, with a DO LOOP in the main code, was necessary to presso ENTER a second time.

_LIMIT 30 makes some 25% less of CPU use!

Code: QB64: [Select]
  1.  
  2. CONST A% = 1 'per prendere un punto ogni A% pixel.
  3. CONST k! = 2 ' coefficiente della x.
  4. CONST m% = 3 'esponente della x.
  5. CONST s! = 10 * k! 'amplificazione di scala delle ascisse.
  6.  
  7. _TITLE "RAPPRESENTAZIONE DELLA FUNZIONE y = kx^m (k =" + STR$(k!) + " ; m =" + STR$(m%) + ")"
  8.  
  9. CONST L% = 1024
  10. CONST H% = 768
  11. CONST rosso = _RGB32(255, 0, 0)
  12. CONST bianco = _RGB32(255, 255, 255)
  13.  
  14. TYPE funzione
  15.     x AS INTEGER
  16.     y AS SINGLE
  17.  
  18. 'DIM SHARED flag%
  19.  
  20. SCREEN _NEWIMAGE(L%, H%, 32)
  21.  
  22. 'DO
  23. disegno ' flag%
  24. '  IF flag% THEN flag% = 0 ELSE EXIT DO
  25. 'LOOP
  26.  
  27.  
  28. SUB disegno () ' (flag%)
  29.     CONST Z% = 43 - 8
  30.  
  31.     DIM titolo1$, titolo2$, punti$, istruzioni$, keypress$
  32.     DIM punti%, i%, n% 'valori di x considerati da -punti% a +punti%, i% e n% sono contatori.
  33.  
  34.     REDIM _PRESERVE funzione(i%) AS funzione
  35.  
  36.     DO ' Double DO/LOOP to allow CHR$(13) Enter press to loop back here. All other presses exit.
  37.         ' REDIM _PRESERVE funzione(i%) AS funzione
  38.  
  39.         i% = 1
  40.         n% = 0
  41.  
  42.         DO 'disegna cartiglio, assi, scrive istruzioni e chiede il n. di punti. non accetta come valore "0".
  43.             CLS
  44.             titolo1$ = "RAPPRESENTAZIONE DELLA FUNZIONE y = kx^m (k =" + STR$(k!) + " ; m =" + STR$(m%) + ")"
  45.             LOCATE 2, ((L% / 8 - LEN(titolo1$)) \ 2): PRINT titolo1$
  46.             titolo2$ = "(Fattore di amplificazione delle ascisse: s = " + STR$(s!) + ")"
  47.             LOCATE 3, ((L% / 8 - LEN(titolo2$)) \ 2): PRINT titolo2$
  48.             VIEW ((L% - 800) \ 2, (H% - 600) \ 2)-((L% - 800) \ 2 + 800, (H% - 600) \ 2 + 600), , rosso 'area grafico 800x600 e pone le coordinate come locali a quest'area.
  49.             CLS
  50.             LINE (799 \ 2, 31)-(799 \ 2, 568), bianco
  51.             LINE (31, 599 \ 2 + 2)-(768, 599 \ 2 + 2), bianco
  52.             PSET (799 \ 2, 31), bianco: DRAW "F20": PSET (799 \ 2, 31), bianco: DRAW "G20": LOCATE 7, 65: PRINT "y"
  53.             PSET (768, 599 \ 2), bianco: DRAW "G20": PSET (768, 599 \ 2), bianco: DRAW "H20": LOCATE 25, 112: PRINT "x"
  54.             LOCATE 25, 63: PRINT "0"
  55.             punti$ = "Inserire il n. di punti in ascissa: "
  56.             LOCATE 5, ((L% / 8 - LEN(punti$) - 1) \ 2)
  57.             PRINT punti$;
  58.             INPUT "", punti%
  59.         LOOP WHILE LTRIM$(STR$(punti%)) = "0"
  60.         n% = -punti%
  61.         DO UNTIL n% = punti% + 1 ' crea il vettore con i valori di x e y i cui elementi vanno da -punti% a +punti%. disegna un cerchio colorato per ogni punto, traslando il grafico in modo che l'orgine non sia in alto a sinistra, ma su "0".
  62.             REDIM _PRESERVE funzione(i%) AS funzione
  63.             funzione(i%).x = n%
  64.             funzione(i%).y = k! * (funzione(i%).x) ^ m
  65.             WINDOW (0, 0)-(799, 599) 'pone il punto (0,0) in basso a sinistra e non scala gli assi x e y.
  66.             CIRCLE (s! * A% * funzione(i%).x + 399, A% * funzione(i%).y + 299), 2, rosso
  67.             PAINT (s! * A% * funzione(i%).x + 399 + 0.5, A% * funzione(i%).y + 299 + 0.5), rosso
  68.             i% = i% + 1
  69.             n% = n% + 1
  70.         LOOP
  71.         FOR i% = 1 TO UBOUND(funzione) - 1 ' congiunge i punti.
  72.             LINE (s! * A% * funzione(i%).x + 399, A% * funzione(i%).y + 299)-(s! * A% * funzione(i% + 1).x + 399, A% * funzione(i% + 1).y + 299), rosso
  73.         NEXT i%
  74.         WINDOW
  75.         VIEW 'elimina l'area del grafico 800x600 e ripristina le coordinate assolute.
  76.         istruzioni$ = "Premere INVIO per un nuovo calcolo, ESC per terminare."
  77.         LOCATE 45, ((L% / 8 - LEN(istruzioni$)) \ 2): PRINT istruzioni$
  78.         LOCATE 7, 16: COLOR rosso: PRINT "Premere " + CHR$(24) + " oppure " + CHR$(25) + "."
  79.         COLOR bianco
  80.         n% = 0
  81.         DO ' stampa le coppie di valori.
  82.             VIEW PRINT 8 TO 43
  83.             FOR i% = (1 + Z% * n%) TO Z% * (n% + 1)
  84.                 SELECT CASE i%
  85.                     CASE UBOUND(funzione) + 1 '--------> not necessary: AND UBOUND(funzione) MOD Z% > 0
  86.                         FOR i% = UBOUND(funzione) + 1 TO (UBOUND(funzione) + Z% - UBOUND(funzione) MOD Z%)
  87.                             LOCATE , 16: PRINT STRING$(27, " ")
  88.                         NEXT i%
  89.                     CASE ELSE
  90.                         LOCATE , 16: PRINT _TRIM$(STR$(i%)) + ")x=" + _TRIM$(STR$(funzione(i%).x)) + ";y=" + _TRIM$(STR$(funzione(i%).y)) + STRING$(8, " ")
  91.                 END SELECT
  92.             NEXT i%
  93.             DO
  94.                 _LIMIT 30 ' Saves CPU so you don't have to install a smoke detector in your laptop.
  95.                 keypress$ = INKEY$
  96.             LOOP UNTIL keypress$ <> ""
  97.             SELECT CASE keypress$
  98.                 CASE CHR$(0) + "H"
  99.                     IF n% > 0 THEN n% = n% - 1
  100.                 CASE CHR$(0) + "P"
  101.                     IF i% < UBOUND(funzione) THEN n% = n% + 1
  102.                 CASE CHR$(27)
  103.                     EXIT DO
  104.                 CASE CHR$(13)
  105.                     VIEW PRINT 'elimina l'area view print.
  106.                     EXIT DO ' flag% = -1 ' Prevents second DO/LOOP exit and redoes the sub from start.
  107.             END SELECT
  108.         LOOP
  109.         IF keypress$ = CHR$(27) THEN EXIT DO '        IF flag% = -1 THEN flag% = 0 ELSE EXIT DO
  110.     LOOP
  111.  
30
QB64 Discussion / Re: What the heck happened to MEM.TYPEs??
« Last post by FellippeHeitor on Yesterday at 04:01:31 PM »
@SMcNeill I've just reset your wiki credentials in case you'd lost them. Please check the email you have associated with your forum account.
Pages: 1 2 [3] 4 5 ... 10