matrix4

--MATRICE6 su ATTIVA
--gestione matrice e SOMMA MATRICI
on mousedown
  repeat with a=1 to 12
    put "" into cd fld a
  end repeat
  put "" into v1
  put "" into v2
  put "" into q1
  put "" into q2
  put "" into s1
  put "" into s2
  put "" into msg
  put "caricamento dati prima matrice"
  repeat with r=1 to 2
    repeat with c=1 to 3
      ask numero
      if r=1 then put v1 & it & " " into v1
      if r=2 then put v2 & it & " " into v2
    end repeat
  end repeat
  put "" into msg
  
  put "caricamento dati seconda matrice"
  repeat with r=1 to 2
    repeat with c=1 to 3
      ask numero
      if r=1 then put v1 & it & " " into q1
      if r=2 then put v2 & it & " " into q2
    end repeat
  end repeat
  put "" into msg
  
  
  put "creazione vettori con elementi inseriti"
  repeat with r=1 to 2
    repeat with c=1 to 3
      if r=1 then put s1 & (word c of v1)+(word c of q1) & " " into s1 
      if r=2 then put s2 & (word c of v2)+(word c of q2) & " " into s2
    end repeat
  end repeat
  put "stampa vettori originali e dopo SOMMA"
  
  repeat with a=1 to 3
    put word a of v1 into cd fld a
  end repeat
  
  put 4 into b
  repeat with a=1 to 3
    put word a of v2 into cd fld b
    add 1 to b
  end repeat
  
  repeat with a=1 to 3
    put word a of q1 into cd fld b
    add 1 to b
  end repeat
  
  repeat with a=1 to 3
    put word a of q2 into cd fld b
    add 1 to b
  end repeat
  
  
  repeat with a=1 to 3
    put word a of s1 into cd fld b
    add 1 to b
  end repeat
  
  
  repeat with a=1 to 3
    put word a of s2 into cd fld b
    add 1 to b
  end repeat
end mousedown 

--MATRICE7 E USO DI FUNCTION E GLOBAL
on mousedown
  global v1,v2,w1,w2,s1,s2,p1,p2,c
  put "" into msg
  put "" into v1
  put "" into v2
  put "" into w1
  put "" into w2
  put "" into s1
  put "" into s2
  put "" into p1
  put "" into p2
  repeat with a=1 to 4
    put "" into cd fld a
  end repeat
  put "scrivi numero colonne :massimo 8"
  ask numero_colonne
  put it into c
  put "richiesta dati prima riga prima matrice"
  go to dati(1)
  put v1 into line 1 of cd fld 1
  put "richiesta dati seconda riga prima matrice"
  go to dati(2)
  put v2 into line 2 of cd fld 1
  put "richiesta dati prima riga seconda matrice"
  go to dati(3)
  put w1 into line 1 of cd fld 2 
  put "richiesta dati seconda riga seconda matrice"
  go to dati(4)
  put w2 into line 2 of cd fld 2
  put "" into msg
  PUT "somma delle due matrici"
  go to somma(1)
  go to somma(2)
  put s1 into line 1 of cd fld 3
  put s2 into line 2 of cd fld 3
  put "prodotto delle matrici"
  go to prodotto(1)
  go to prodotto(2)
  put p1 into line 1 of cd fld 4
  put p2 into line 2 of cd fld 4
  put "" into msg
end mousedown
function dati v
  global v1,v2,w1,w2
  ask "dati riga separati da spazio"  
  if v=1 then put it into v1
  if v=2 then put it into v2
  if v=3 then put it into w1
  if v=4 then put it into w2
end dati
function somma n
  global s1,s2,v1,v2,w1,w2,c
  repeat with b=1 to c
    if n=1 then put s1 & (word b of v1)+(word b of w1) & " " into s1
    if n=2 then put s2 & (word b of v2)+(word b of w2) & " " into s2
  end repeat
end somma
function prodotto n
  global p1,p2,v1,v2,w1,w2,c
  repeat with b=1 to c
    if n=1 then put p1 & (word b of v1)*(word b of w1) & " " into p1
    if n=2 then put p2 & (word b of v2)*(word b of w2) & " " into p2
  end repeat
end prodotto