Author Topic: Problem with CLEAR  (Read 5362 times)

0 Members and 1 Guest are viewing this topic.

Offline bartok

  • Newbie
  • Posts: 80
    • View Profile
Re: Problem with CLEAR
« Reply #15 on: June 28, 2021, 03:06:38 am »
We've had a few corner cases like this one since the introduction of variable-width strings in types. Do you get the same problem with CLEAR if you declare your element as a fixed string element? For example:

Code: QB64: [Select]
  1.     T AS STRING * 256

No, in this way it doesn't crash:
Code: QB64: [Select]
  1.     CLEAR
  2.  
  3.     CLS
  4.     OPTION BASE 1
  5.  
  6.  
  7.     TempiRitorno:
  8.     DATA 0,2,5,10,20,50,100,200,500,1000: '------------------------------------------------------>removed text end changed with "0".
  9.     DATA 1,0.82,1.24,1.46,1.69,2.04,2.34,2.70,3.22,3.64
  10.     CoefficientiIdrogrammaUnitarioMockus: 'dati dell'idrogramma unitario di Mockus
  11.     DATA 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5: 't/ta
  12.     DATA 0.03,0.1,0.19,0.31,0.47,0.66,0.82,0.93,0.99,1,0.99,0.93,0.86,0.78,0.68,0.56,0.46,0.39,0.33,0.28,0.244,0.207,0.177,0.147,0.127,0.107,0.092,0.077,0.066,0.055,0.048,0.04,0.035,0.029,0.025,0.021,0.018,0.015,0.013,0.011,0.009,0.008,0.007,0.006,0.006,0.005,0.004,0.003,0.001,0: ' t/tp
  13.  
  14.     TYPE mockus
  15.         tSUta AS SINGLE
  16.         qSUqp AS SINGLE
  17.     END TYPE
  18.     TYPE TempiRitorno
  19.         T AS STRING * 10 '-------------------------------------------------------------------------->changed STRING to SINGLE
  20.         k AS SINGLE
  21.     END TYPE
  22.     DIM SHARED i%, n%, z%, ieto%, VisualizzaIeto%
  23.     DIM SHARED TempiRitorno(10) AS TempiRitorno
  24.     DIM mockus(50) AS mockus
  25.  
  26.  
  27.     ' 'RESTORE group 1:
  28.     RESTORE TempiRitorno
  29.     FOR i% = 1 TO 20
  30.         IF i% <= 10 THEN READ TempiRitorno(i%).T
  31.         IF i% > 10 THEN READ TempiRitorno(i% - 10).k
  32.     NEXT i%
  33.  
  34.     ' 'RESTORE group 2:
  35.     RESTORE CoefficientiIdrogrammaUnitarioMockus
  36.     FOR i% = 1 TO 100
  37.         IF i% <= 50 THEN READ mockus(i%).tSUta
  38.         IF i% > 50 THEN READ mockus(i% - 50).qSUqp
  39.     NEXT i%
  40.  
  41.  
  42.     '[...]
  43.     PRINT
  44.     PRINT "- Restart program? [Y/N]"
  45.     DO
  46.         _LIMIT 50
  47.         KeyPress$ = LCASE$(INKEY$)
  48.     LOOP UNTIL KeyPress$ = "y" OR KeyPress$ = "n"
  49.     IF KeyPress$ = "n" THEN EXIT DO
  50.  
  51.