Altro programma in QBasic che non funziona

di il
3 risposte

Altro programma in QBasic che non funziona

Salve, ho scritto un programma in QBasic 64 che dovrebbe simulare il comportamento di un gas di particelle in espansione libera sotto l'azione della reciproca forza di gravità. L'impianto del programma è uguale a quello di un altro listato di cui ho scritto nel thread “Programma in QBasic difettoso” ma alquanto semplificato. Per motivi che ancora non riesco a comprendere il programma va in blocco subito dopo l'inserimento del numero N di corpi: lo schermo diventa completamente nero, i comandi non rispondono, neppure quello di ESC-uscita, e a quel punto sono costretto a terminarlo di forza con l'apposita funzione di Windows.

$Debug
' dimensiona e definisci funzioni
Dim G As Double, VC As Double, AL As Double
Dim it As Double, pr As Double, dt As Double, pigreco As Double
Dim nc As Integer, ncmax As Integer, Nt As Integer
Dim N1 As Integer, N2 As Integer
Dim Mmax As Integer
Dim dq0 As Single, dq As Single
Dim fndist As Double
Dim Distmax0 As Double, Distmax1 As Double
Dim acc As Double
Dim k As Double, L As Integer, C As Integer
Dim lo As Integer, lv As Integer
Dim pm As Integer, primo As Integer
Dim I1 As Integer, I2 As Integer
Dim diag1 As Integer, diag2 As Integer
Dim AK As Integer
Dim scr As Integer, col As Integer
Dim m1 As Integer, m2 As Integer, den As Single
Dim Ep As Double, Epmax As Double, Epmin As Double, Epmed As Double
Dim Ec As Double, Ecmax As Double, Ecmin As Double, Ecmed As Double
Dim Etot As Double, Etmax As Double, Etmin As Double, Etmed As Double
Dim Sen As Double, Senmax As Double, Senmin As Double, Senmed As Double
ncmax = 100 ' Numero massimo corpi iniziali
lo = 639: lv = 479 ' Limiti grafici
Dim M0(ncmax) As Double, M(ncmax) As Double
Dim R0(ncmax) As Double, R(ncmax) As Double, Rg(ncmax) As Integer
Dim x0(ncmax) As Double, y0(ncmax) As Double, z0(ncmax) As Double
Dim x(ncmax) As Double, y(ncmax) As Double, z(ncmax) As Double
Dim xa(ncmax) As Double, ya(ncmax) As Double, za(ncmax) As Double
Dim xf(ncmax) As Double, yf(ncmax) As Double, zf(ncmax) As Double
Dim xx1(ncmax) As Integer, yy1(ncmax) As Integer
Dim xx2(ncmax) As Integer, yy2(ncmax) As Integer
Dim zz1(ncmax) As Integer, zz2(ncmax) As Integer, prof(ncmax) As Integer
Dim vt(ncmax) As Double
Dim vx(ncmax) As Double, vy(ncmax) As Double, vz(ncmax) As Double
Dim Dist(ncmax, ncmax) As Double
Dim Ep(ncmax, ncmax) As Double, Ec(ncmax) As Double
Dim Epg(lo) As Integer, Epmedg(lo) As Integer
Dim Ecg(lo) As Integer, Ecmedg(lo) As Integer
Dim Etg(lo) As Integer, Etmedg(lo) As Integer
Dim Seng(lo) As Integer, Senmedg(lo) As Integer
Randomize Timer

'
'     - Costanti -
G = .0000000000667259# ' Costante gravitaz. universale
VC = 299792458 ' Velocita' luce
AL = VC * 31558149.5# ' Anno-luce
pr = 100 ' Precisione
pigreco = 3.14159265359#

'     - Inizio -
Screen 9, , 0: _FullScreen: L = 6: C = 1: nc = 10
Cls: Locate 2, 20: Color 11: Print " GAS UNIVERSO ": Color 2
Print " - Simulazione del moto di particelle sotto l'azione della forza di gravita'"
Print " " + String$(64, 196): Print Space$(46) + "(Premere un tasto)"
Window (0, lv)-(lo, 0)
GoSub comandi
Cls: PCopy 0, 1
'
parametri:
Cls: I1 = 0: I2 = 0
x = 0: y = pigreco: z = 0 ' angoli di Eulero
130 dq0 = 1
140 Cls: PCopy 1, 0: Locate 2, 1
L = 2: C = 28: Print "Numero corpi ( max."; ncmax; "):"; nc
GoSub scrivi: nc = N
If nc < 2 Then nc = 2: GoTo 140
If nc > ncmax Then nc = ncmax: GoTo 140
'             velocit… iniziali
For N1 = 1 To nc

    '             funzione di distribuzione maxwelliana
    dm = 0: For k = 1 To 3: dm = dm + Sin(Rnd * pigreco): Next
    dm = dm * Sqr(2 / 3)
    dm = 1 - (Sin(Rnd * pigreco) + dm) / (1 + 3 * Sqr(2 / 3))
    'vx(N1) = dm * AL / 4 * Sgn(Rnd * 3 - 2)
    dm = 0: For k = 1 To 3: dm = dm + Sin(Rnd * pigreco): Next
    dm = dm * Sqr(2 / 3)
    dm = 1 - (Sin(Rnd * pigreco) + dm) / (1 + 3 * Sqr(2 / 3))
    'vy(N1) = dm * AL / 4 * Sgn(Rnd * 3 - 2)
    dm = 0: For k = 1 To 3: dm = dm + Sin(Rnd * pigreco): Next
    dm = dm * Sqr(2 / 3)
    dm = 1 - (Sin(Rnd * pigreco) + dm) / (1 + 3 * Sqr(2 / 3))
    'vz(N1) = dm * AL / 4 * Sgn(Rnd * 3 - 2)
    vx(N1) = Rnd * 300 - 300: vy(N1) = Rnd * 300 - 300: vz(N1) = Rnd * 300 - 300
Next N1

'             posizioni e masse iniziali
For N1 = 1 To nc
    x(N1) = Rnd * AL - AL
    y(N1) = Rnd * AL - AL
    z(N1) = Rnd * AL - AL
    M0(N1) = 1: R0(N1) = 1
Next N1
GoSub distmax
dq = dq0: ' dim. quadro schermo
GoSub pargraf: GoSub calcint
'
'     - Inizializzazione -
190 For N1 = 1 To nc
    xx1(N1) = -1: yy1(N1) = -1: xx2(N1) = -1: yy2(N1) = -1
Next N1
200 Screen 9, , 1: Cls
210 Screen 9, , 0: PCopy 1, 0
If I1 Then 240
If I2 Then 260
240 If diag1 Or diag2 Then PCopy 1, 0
If Nt = 1 Then Cls: PCopy 0, 1
For N1 = 1 To nc
    M(N1) = M0(N1): R(N1) = R0(N1): Rg(N1) = R(N1)
    xx1(N1) = -1: yy1(N1) = -1: xx2(N1) = -1: yy2(N1) = -1
Next N1
For N1 = 1 To nc: If M(N1) = 0 Then 250
    x(N1) = x0(N1): y(N1) = y0(N1): z(N1) = z0(N1)
    For N2 = 1 To nc: If N2 = N1 Or M(N2) = 0 Then 241
        Dist(N1, N2) = Sqr((x(N1) - x(N2)) ^ 2 + (y(N1) - y(N2)) ^ 2 + (z(N1) - z(N2)) ^ 2)
        Dist(N2, N1) = Dist(N1, N2)
    241 Next N2
250 Next N1
ao = 320.5: oo = 240.5 ' coord. centro schermo
t = 0: I1 = 0: I2 = 0: Nt = nc
pm = 0: primo = 0
Epmax = 0: Epmin = -1D+300
Ecmax = 0: Ecmin = 1D+300
Etmax = 0: Etmin = -1D+300
Senmax = 0: Senmin = -1D+300
'
'     - Calcolo matematico -
' - Calcolo precisione tempo -
260 dt = Abs(it / pr)
For k = 1 To pr
    For N1 = 1 To nc: If M(N1) = 0 Then 280
        For N2 = 1 To nc: If N2 = N1 Or M(N2) = 0 Then 270
            Dist(N1, N2) = Sqr((x(N1) - x(N2)) ^ 2 + (y(N1) - y(N2)) ^ 2 + (z(N1) - z(N2)) ^ 2)
            Dist(N2, N1) = Dist(N1, N2)
        270 Next N2
    280 Next N1
    For N1 = 1 To nc: If M(N1) = 0 Then 291
        xa(N1) = 0: ya(N1) = 0: za(N1) = 0
        If Nt > 1 Then
            For N2 = 1 To nc: If N2 = N1 Or M(N2) = 0 Then 290
                acc = G * M(N2) / Dist(N1, N2) ^ 3
                xa(N1) = xa(N1) + acc * (x(N2) - x(N1))
                ya(N1) = ya(N1) + acc * (y(N2) - y(N1))
                za(N1) = za(N1) + acc * (z(N2) - z(N1))
            290 Next N2
        End If
    291 Next N1
    For N1 = 1 To nc: If M(N1) = 0 Then 292
        If Nt > 1 Then
            vx(N1) = vx(N1) + xa(N1) * dt
            vy(N1) = vy(N1) + ya(N1) * dt
            vz(N1) = vz(N1) + za(N1) * dt
            vt(N1) = Sqr(vx(N1) ^ 2 + vy(N1) ^ 2 + vz(N1) ^ 2)
        End If
    292 Next N1
    For N1 = 1 To nc: If M(N1) = 0 Then 300
        xf(N1) = x(N1) + vx(N1) * dt
        yf(N1) = y(N1) + vy(N1) * dt
        zf(N1) = z(N1) + vz(N1) * dt
    300 Next N1
    For N1 = 1 To nc: If M(N1) = 0 Then 330
        x(N1) = xf(N1): y(N1) = yf(N1): z(N1) = zf(N1)
        GoSub distmax
        '
        '     - Controlli -
        For N2 = 1 To nc: If N2 = N1 Or M(N2) = 0 Then 320
            Dist(N1, N2) = Sqr((x(N1) - x(N2)) ^ 2 + (y(N1) - y(N2)) ^ 2 + (z(N1) - z(N2)) ^ 2)
            Dist(N2, N1) = Dist(N1, N2)
            310 If Dist(N1, N2) > R(N1) + R(N2) Then 320
            '
            ' altrimenti...
            '
            '     - Collisione-fusione -
            'Sound 200, .1
            Cls: PCopy 0, 1: Nt = Nt - 1
            m1 = N1: m2 = N2: If M(N2) > M(N1) Then Swap m1, m2
            den = M(m1) * 3 / 4 / pigreco / R(m1) ^ 3
            vx(m1) = (M(m1) * vx(m1) + M(m2) * vx(m2)) / (M(m1) + M(m2)): vx(m2) = 0
            vy(m1) = (M(m1) * vy(m1) + M(m2) * vy(m2)) / (M(m1) + M(m2)): vy(m2) = 0
            vz(m1) = (M(m1) * vz(m1) + M(m2) * vz(m2)) / (M(m1) + M(m2)): vz(m2) = 0
            M(m1) = M(m1) + M(m2): M(m2) = 0
            R(m1) = ((M(m1) / den) * 3 / 4 / pigreco) ^ (1 / 3)
            Rg(m1) = R(m1) * kx
            pm = 0: primo = 0
            Epmax = 0: Epmin = -1D+300
            Ecmax = 0: Ecmin = 1D+300
            Etmax = 0: Etmin = -1D+300
            Senmax = 0: Senmin = -1D+300
            GoTo 260
            '
        320 Next N2
    330 Next N1
Next k: t = t + it
'
' calcolo energia istantanea, massima, minima e media
Ep = 0: Ec = 0
For N1 = 1 To nc: If M(N1) = 0 Then 350
    For N2 = 1 To nc: If N2 = N1 Or M(N2) = 0 Then 340
        fndist = Sqr((x(N1) - x(N2)) ^ 2 + (y(N1) - y(N2)) ^ 2 + (z(N1) - z(N2)) ^ 2)
        Ep(N1, N2) = -G * M(N1) * M(N2) / fndist
        Ep = Ep + Ep(N1, N2)
    340 Next N2
    Ec(N1) = vt(N1) ^ 2 * M(N1) / 2: Ec = Ec + Ec(N1)
350 Next N1
Ep = Ep / 2: Etot = Ep + Ec
If Abs(Ep) > Abs(Epmax) Then Epmax = Ep
If Abs(Ep) < Abs(Epmin) Then Epmin = Ep
If Ec > Ecmax Then Ecmax = Ec
If Ec < Ecmin Then Ecmin = Ec
If Abs(Etot) > Abs(Etmax) Then Etmax = Etot
If Abs(Etot) < Abs(Etmin) Then Etmin = Etot
Epmed = (Epmax + Epmin) / 2
Ecmed = (Ecmax + Ecmin) / 2
Etmed = (Etmax + Etmin) / 2
Sen = Etot / Ec ' entropia
If Abs(Sen) > Abs(Senmax) Then Senmax = Sen
If Abs(Sen) < Abs(Senmin) Then Senmin = Sen
Senmed = (Senmax + Senmin) / 2
'
' fsd = fattore scala diagrammi
If primo = 0 Then
    If Epmin > -1D+300 Then
        fsd1 = (lv - 1) / Abs(Epmin) / 5
    Else fsd1 = (lv - 1) / Abs(Ep) / 5
    End If
    If Ep = 0 Then fsd1 = (lv - 1) / Ec / 2
    If Senmin > -1D-300 Then
        fsd2 = 0.9 * (lv - 1) / Abs(Senmin) / 2
    Else fsd2 = 0.9 * (lv - 1) / Abs(Sen) / 2
    End If
    If Sen = 0 Then fsd2 = 0.9 * (lv - 1) / 2
    primo = 1
End If
Epg = Ep * fsd1 + (lv - 1) / 2
If Epg > lv - 1 Or Epg < 0 Then fsd1 = fsd1 / 2: pm = lo
Epmedg = Epmed * fsd1 + (lv - 1) / 2
If Epmedg > lv - 1 Or Epmedg < 0 Then fsd1 = fsd1 / 2: pm = lo
Ecg = Ec * fsd1 + (lv - 1) / 2
If Ecg > lv - 1 Or Ecg < 0 Then fsd1 = fsd1 / 2: pm = lo
Ecmedg = Ecmed * fsd1 + (lv - 1) / 2
If Ecmedg > lv - 1 Or Ecmedg < 0 Then fsd1 = fsd1 / 2: pm = lo
Etg = Etot * fsd1 + (lv - 1) / 2
If Etg > lv - 1 Or Etg < 0 Then fsd1 = fsd1 / 2: pm = lo
Etmedg = Etmed * fsd1 + (lv - 1) / 2
If Etmedg > lv - 1 Or Etmedg < 0 Then fsd1 = fsd1 / 2: pm = lo
Seng = Sen * fsd2 + (lv - 1) / 2
If Seng > lv - 1 Or Seng < 0 Then fsd2 = fsd2 / 2: pm = lo
Senmedg = Senmed * fsd2 + (lv - 1) / 2
If Senmedg > lv - 1 Or Senmedg < 0 Then fsd2 = fsd2 / 2: pm = lo
pm = pm + 1
If pm > lo / 6 Then
    pm = 0: If diag1 Or diag2 Then Cls: PCopy 1, 0
End If
Epg(pm) = Epg: Epmedg(pm) = Epmedg
Ecg(pm) = Ecg: Ecmedg(pm) = Ecmedg
Etg(pm) = Etg: Etmedg(pm) = Etmedg
Seng(pm) = Seng: Senmedg(pm) = Senmedg
'
GoSub grafica ' <- routine grafica
'
A$ = InKey$: If A$ = "" Then 260
If A$ = "e" Then L = 3: C = 3: GoSub comandi: I2 = 1: GoTo 210
If A$ = "p" Then GoTo parametri
If A$ = "t" Then
    For N1 = 1 To nc: vx(N1) = -vx(N1): vy(N1) = -vy(N1): Next N1
    it = -it
End If
If A$ = "n" Then dq = dq0: GoSub pargraf: I1 = 1: GoTo 200
If A$ = "c" Then Cls: PCopy 0, 1
If A$ = "h" Then GoSub 4000: GoTo 260
If A$ = "<" Then
    dq = dq * 2
    GoSub pargraf: I2 = 1: GoTo 190
End If
If A$ = ">" Then
    dq = dq / 2: If dq < .001 Then dq = .001
    GoSub pargraf: I2 = 1: GoTo 190
End If
If A$ = " " Then GoSub dati: I2 = 1: GoTo 210
If A$ = "!" Then
    diag1 = -(diag1 = 0): diag2 = 0
    pm = lo
    Cls: PCopy 1, 0
End If
If Asc(A$) = 34 Then
    diag2 = -(diag2 = 0): diag1 = 0
    pm = lo
    Cls: PCopy 1, 0
End If
If A$ = "x" Or A$ = "X" Or A$ = "y" Or A$ = "Y" Or A$ = "z" Or A$ = "Z" Then
    If A$ = "x" Then x = x + 5 * pigreco / 180
    If x > (355 * pigreco / 180) Then x = 0
    If A$ = "X" Then x = x - 5 * pigreco / 180
    If x < -(355 * pigreco / 180) Then x = 0
    If A$ = "y" Then y = y + 5 * pigreco / 180
    If y > (445 * pigreco / 180) Then y = pigreco / 2
    If A$ = "Y" Then y = y - 5 * pigreco / 180
    If y < -(265 * pigreco / 180) Then y = pigreco / 2
    If A$ = "z" Then z = z - 5 * pigreco / 180
    If z < -(355 * pigreco / 180) Then z = 0
    If A$ = "Z" Then z = z + 5 * pigreco / 180
    If z > (355 * pigreco / 180) Then z = 0
    dq = dq0: GoSub pargraf: I2 = 1: GoTo 190
End If
If Len(A$) >= 2 Then
    AK = Asc(Right$(A$, 1))
    If AK = 72 Then oo = oo + 10
    If AK = 80 Then oo = oo - 10
    If AK = 75 Then ao = ao - 10
    If AK = 77 Then ao = ao + 10
    dq = dq0: GoSub pargraf: I2 = 1: GoTo 190
End If
If A$ = Chr$(27) Then Screen 0: End
GoTo 260
'
'     - Routines -
grafica:
Screen 9, , 0
For N1 = 1 To nc: If M(N1) = 0 Then 1001
    If xx1(N1) > 0 And xx1(N1) < lo And yy1(N1) > 0 And yy1(N1) < lv Then
        For scr = 0 To 1
            Screen 9, , scr, 0
            Circle (xx1(N1), yy1(N1)), Rg(N1), 0, , , 1
        1000 Next scr
    End If
1001 Next N1
1002 For N1 = 1 To nc: If M(N1) = 0 Then 1003
    xx1(N1) = ((Cos(x) * Cos(z) + Sin(x) * Cos(y) * Sin(z)) * (x(N1) * 0.75) + (-Sin(x) * Cos(z) + Cos(x) * Cos(y) * Sin(z)) * y(N1) + (Sin(y) * Sin(z)) * z(N1)) * kx + ao
    yy1(N1) = ((-Cos(x) * Sin(z) - Sin(x) * Cos(y) * Cos(z)) * (x(N1) * 0.75) + (Sin(x) * Sin(z) - Cos(x) * Cos(y) * Cos(z)) * y(N1) + (Sin(y) * Cos(z)) * z(N1)) * kx + oo
    zz1(N1) = ((Sin(x) * Sin(y)) * (x(N1) * 0.75) + (Cos(x) * Sin(y)) * y(N1) + Cos(y) * z(N1)) * kx + ao
    If xx1(Mmax) < -1 Or xx1(Mmax) > lo Or yy1(Mmax) < -1 Or yy1(Mmax) > lv Then
        If xx1(Mmax) < -1 Then ao = ao + lo / 2
        If xx1(Mmax) > lo Then ao = ao - lo / 2
        If yy1(Mmax) < -1 Then oo = oo + lv / 2
        If yy1(Mmax) > lv Then oo = oo - lv / 2
        Screen 9, , 0, 0: Cls: PCopy 0, 1: GoTo 1002
    End If
1003 Next N1
GoSub zprof1
For N1 = 1 To nc: If M(prof(N1)) = 0 Then 1006
    If xx1(N1) < -1 Or xx1(N1) > lo Or yy1(N1) < -1 Or yy1(N1) > lv Then
        dq = dq * 2
        GoSub pargraf: I2 = 1: GoTo 190
    End If
    For N2 = 2 To nc: If M(prof(N2)) = 0 Then 1005
        For scr = 0 To 1
            Screen 9, , scr, 0
            col = 14
            If Sqr((xx1(prof(N1)) - xx1(prof(N2))) ^ 2 + (yy1(prof(N1)) - yy1(prof(N2))) ^ 2) > Rg(prof(N1)) + Rg(prof(N2)) Then
                Circle (xx1(prof(N1)), yy1(prof(N1))), Rg(prof(N1)), col, , , 1
                GoTo 1004
            End If
            If zz1(prof(N1)) < zz1(prof(N2)) Then
                If Rg(prof(N2)) >= Rg(prof(N1)) Then
                    Circle (xx1(prof(N2)), yy1(prof(N2))), Rg(prof(N2)), col, , , 1
                End If
                Circle (xx1(prof(N1)), yy1(prof(N1))), Rg(prof(N1)), col, , , 1
            Else
                If Rg(prof(N1)) >= Rg(prof(N2)) Then
                    Circle (xx1(prof(N1)), yy1(prof(N1))), Rg(prof(N1)), col, , , 1
                End If
                Circle (xx1(prof(N2)), yy1(prof(N2))), Rg(prof(N2)), col, , , 1
            End If
        1004 Next scr
    1005 Next N2
1006 Next N1
Screen 9, , 0
Locate 21, 69: Color 15: Print "x ="; CInt(x * 180 / pigreco);
Locate 22, 69: Color 15: Print "y ="; CInt(y * 180 / pigreco - 90);
Locate 23, 69: Color 15: Print "z ="; CInt(z * 180 / pigreco);
Screen 9, , 0: Locate 24, 69: Color 15: Print "dq ="; dq;
'
'             traccia ENERGIA TOTALE
If diag1 Then
    Locate 25, 2: Color 15: Print "energia ";
    Color 14: Print "potenziale";: Color 15: Print ", ";
    Color 4: Print "cinetica";: Color 15: Print ", ";
    Color 2: Print "totale";
    Line (0, (lv - 1) / 2)-(lo, (lv - 1) / 2), 15
    ' en. potenziale istantanea
    PSet (0, Epg(0)), 14: fl% = 1
    For k = 1 To pm
        xx = k * 6
        If fl% Then PSet (xx, Epg(k)), 14: fl% = 0
        Line -(xx, Epg(k)), 14
    Next
    ' en. cinetica istantanea
    PSet (0, Ecg(0)), 4: fl% = 1
    For k = 1 To pm
        xx = k * 6
        If fl% Then PSet (xx, Ecg(k)), 4: fl% = 0
        Line -(xx, Ecg(k)), 4
    Next
    ' en. totale istantanea
    PSet (0, Etg(0)), 2: fl% = 1
    For k = 1 To pm
        xx = k * 6
        If fl% Then PSet (xx, Etg(k)), 2: fl% = 0
        Line -(xx, Etg(k)), 2
    Next
    ' en. potenziale media
    PSet (0, Epmedg(0)), 15
    For k = 1 To pm
        xx = k * 6
        PSet (xx, Epmedg(k)), 15
    Next
    ' en. cinetica media
    PSet (0, Ecmedg(0)), 15
    For k = 1 To pm
        xx = k * 6
        PSet (xx, Ecmedg(k)), 15
    Next
    ' en. totale media
    PSet (0, Etmedg(0)), 15
    For k = 1 To pm
        xx = k * 6
        PSet (xx, Etmedg(k)), 15
    Next
End If
'
'             traccia ENTROPIA
If diag2 Then
    Locate 25, 2: Color 9: Print "entropia (Etot/Ecin)";
    Line (0, (lv - 1) / 2)-(lo, (lv - 1) / 2), 15
    ' entropia istantanea
    PSet (0, Seng(0)), 9: fl% = 1
    For k = 1 To pm
        xx = k * 6
        If fl% Then PSet (xx, Seng(k)), 9: fl% = 0
        Line -(xx, Seng(k)), 9
    Next
    ' entropia media
    PSet (0, Senmedg(0)), 15
    For k = 1 To pm
        xx = k * 6
        PSet (xx, Senmedg(k)), 15
    Next
End If
'
Return
'
dati:
'     - Stampa dati -
Locate 2, 1: Color 3
Print "Tempo =";
tanni = 0: tmesi = 0: tgiorni = 0: tore = 0: tminuti = 0: tsecondi = 0
tanni = Int(t / 31536000)
tmesi = Int((t - (tanni * 31536000)) / 2592000)
tgiorni = Int((t - (tanni * 31536000) - (tmesi * 2592000)) / 86400)
tore = Int((t - (tanni * 31536000) - (tmesi * 2592000) - (tgiorni * 86400)) / 3600)
tminuti = Int((t - (tanni * 31536000) - (tmesi * 2592000) - (tgiorni * 86400) - (tore * 3600)) / 60)
tsecondi = Int(t - (tanni * 31536000) - (tmesi * 2592000) - (tgiorni * 86400) - (tore * 3600) - (tminuti * 60))
Print tanni; "yr"; tmesi; "mo"; tgiorni; "d"; tore; "h"; tminuti; "m"; tsecondi; "s ";
Print "="; t; "sec "
Print "Num. corpi ="; Nt
Color 14: Print " En. potenziale    = "; Ep; "Joule "
Color 4: Print " En. cinetica      = "; Ec
Color 2: Print " En. totale        = "; Etot
Color 15: Print " En. pot. media    = "; Epmed; "Joule "
Print " En. cin. media    = "; Ecmed
Print " En. tot. media    = "; Etmed
Color 9: Print " Entropia (Etot/Ecin) = "; Sen
Color 15: Print " Entr. media          = "; Senmed;
3000 A$ = InKey$: If A$ = "" Then 3000
Return
'
comandi:
Color 6: Locate L, C: Print "Comandi:"
Locate , C: Print "[e] elenco comandi"
Locate , C: Print "[p] parametri"
Locate , C: Print "[q] dim. quadro"
Locate , C: Print "[t] inverti tempo"
Locate , C: Print "[n] di nuovo"
Locate , C: Print "[c] pulisci schermo"
Locate , C: Print "[</>] aum./rid. dim. quadro"
Locate , C: Print "[" + Chr$(27) + Chr$(18) + Chr$(26) + "] sposta fin. schermo"
Locate , C: Print "[h] halt"
Locate , C: Print "[ ] dati globali"
Locate , C: Print "[SH+1] mostra/nascondi diagr. energia"
Locate , C: Print "[SH+2] mostra/nascondi diagr. entropia"
Locate , C: Print "[x] ruota x in senso antiorario"
Locate , C: Print "[X] ruota x in senso orario"
Locate , C: Print "[y] ruota y in senso antiorario"
Locate , C: Print "[Y] ruota y in senso orario"
Locate , C: Print "[z] ruota z in senso antiorario"
Locate , C: Print "[Z] ruota z in senso orario"
Locate , C: Print "[ESC] fine";
4000 A$ = InKey$: If A$ = "" Then 4000
If A$ = Chr$(27) Then Screen 0: End
Return
'
distmax:
Distmax0 = 0: Distmax1 = Distmax0
For N1 = 1 To nc: If M(N1) = 0 Then 5000
    Distmax1 = Sqr(x(N1) ^ 2 + y(N1) ^ 2 + z(N1) ^ 2): If Distmax1 > Distmax0 Then Distmax0 = Distmax1
5000 Next N1
Return
'
pargraf:
' - Calcolo parametri grafici -
kx = lo / Distmax0 / dq / 2
For N1 = 1 To nc: Rg(N1) = R(N1) * kx: Next
primo = 1
Return
'
calcint:
vmax = 0
For N1 = 1 To nc: If M0(N1) = 0 Then 10000
    v(N1) = Sqr(vx(N1) ^ 2 + vy(N1) ^ 2 + vz(N1) ^ 2)
    If v(N1) > vmax Then vmax = v(N1)
10000 Next N1
it = Int(Distmax0 / vmax / 200)
Return

'
zprof1:
For N1 = 1 To nc: If M(N1) = 0 Then 13000
    prof(N1) = N1
13000 Next N1
For N1 = 1 To nc: If M(N1) = 0 Then 13002
    For N2 = N1 + 1 To nc: If M(N2) = 0 Then 13001
        If zz1(N1) < zz1(N2) Then Swap prof(N2), prof(N1)
    13001 Next N2
13002 Next N1
Return

zprof2:
For N1 = 1 To nc: If M(N1) = 0 Then 14000
    prof(N1) = N1
14000 Next N1
For N1 = 1 To nc: If M(N1) = 0 Then 14002
    For N2 = N1 + 1 To nc: If M(N2) = 0 Then 14001
        If zz2(N1) < zz2(N2) Then Swap prof(N2), prof(N1)
    14001 Next N2
14002 Next N1
Return
'
scrivi:
Locate L, C: Input "", W: N$ = ""
For k = C To C + 30: N$ = N$ + Chr$(Screen(L, k)): Next
N = Val(N$): Return
'
End

3 Risposte

Devi accedere o registrarti per scrivere nel forum
3 risposte