ces fonctions servent a echanger des lignes et des colonnes
ca marche pour les long , float , word , byte
je l ai pas fait avec les string parceque je ni arrive pas ^^
Code : Tout sélectionner
Procedure ShowBoardL(*board.long, Dimx, Dimy); retourne le tableau sur le debugeur *board > adresse du tableau, dim x/y > dimention du tableau
fin = (Dimx + 1) * (Dimy + 1)
text.s = ""
x = 0
For i = 1 To fin
x = x + 1
text = text + " | " + Str(*board\l)
*board + 4
If x = Dimx + 1
x = 0
Debug Text + " |"
a.s = LSet$("=", Len(text) - 5, "=")
Debug a
text = ""
EndIf
Next
EndProcedure
Procedure ShowBoardF(*board.Float, Dimx, Dimy); retourne le tableau sur le debugeur *board > adresse du tableau, dim x/y > dimention du tableau
fin = (Dimx + 1) * (Dimy + 1)
text.s = ""
x = 0
For i = 1 To fin
x = x + 1
text = text + " | " + StrF(*board\f)
*board + 4
If x = Dimx + 1
x = 0
Debug Text + " |"
a.s = LSet$("=", Len(text) - 5, "=")
Debug a
text = ""
EndIf
Next
EndProcedure
Procedure ShowBoardW(*board.Word, Dimx, Dimy); retourne le tableau sur le debugeur *board > adresse du tableau, dim x/y > dimention du tableau
fin = (Dimx + 1) * (Dimy + 1)
text.s = ""
x = 0
For i = 1 To fin
x = x + 1
text = text + " | " + Str(*board\w)
*board + 2
If x = Dimx + 1
x = 0
Debug Text + " |"
a.s = LSet$("=", Len(text) - 5, "=")
Debug a
text = ""
EndIf
Next
EndProcedure
Procedure ShowBoardB(*board.Byte, Dimx, Dimy); retourne le tableau sur le debugeur *board > adresse du tableau, dim x/y > dimention du tableau
fin = (Dimx + 1) * (Dimy + 1)
text.s = ""
x = 0
For i = 1 To fin
x = x + 1
text = text + " | " + Str(*board\b)
*board + 1
If x = Dimx + 1
x = 0
Debug Text + " |"
a.s = LSet$("=", Len(text) - 5, "=")
Debug a
text = ""
EndIf
Next
EndProcedure
ProcedureDLL SwapLineBoardL(*board.Long, Dimx, Dimy, ligne1, ligne2); échange les lignes ligne1 et ligne2 *board > adresse du tableau de type long
x = 0
y = 0
*mem.Long = *board.Long
Dim ligne1(Dimx)
Dim ligne2(Dimx)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
ligne1(x) = *board\l
EndIf
If y = ligne2
ligne2(x) = *board\l
EndIf
*board + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
*mem\l = ligne2(x)
EndIf
If y = ligne2
*mem\l = ligne1(x)
EndIf
*mem + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
ProcedureDLL SwapLineBoardF(*board.Float, Dimx, Dimy, ligne1, ligne2); échange les lignes ligne1 et ligne2 *board > adresse du tableau de type float
x = 0
y = 0
*mem.Float = *board.Float
Dim ligne1(Dimx)
Dim ligne2(Dimx)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
ligne1(x) = *board\f
EndIf
If y = ligne2
ligne2(x) = *board\f
EndIf
*board + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
*mem\f = ligne2(x)
EndIf
If y = ligne2
*mem\f = ligne1(x)
EndIf
*mem + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
ProcedureDLL SwapLineBoardW(*board.Word, Dimx, Dimy, ligne1, ligne2); échange les lignes ligne1 et ligne2 *board > adresse du tableau de type word
x = 0
y = 0
*mem.Word = *board.Word
Dim ligne1(Dimx)
Dim ligne2(Dimx)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
ligne1(x) = *board\w
EndIf
If y = ligne2
ligne2(x) = *board\w
EndIf
*board + 2
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
*mem\w = ligne2(x)
EndIf
If y = ligne2
*mem\w = ligne1(x)
EndIf
*mem + 2
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
ProcedureDLL SwapLineBoardB(*board.Byte, Dimx, Dimy, ligne1, ligne2); échange les lignes ligne1 et ligne2 *board > adresse du tableau de type byte
x = 0
y = 0
*mem.Byte = *board.Byte
Dim ligne1(Dimx)
Dim ligne2(Dimx)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
ligne1(x) = *board\b
EndIf
If y = ligne2
ligne2(x) = *board\b
EndIf
*board + 1
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If y = ligne1
*mem\b = ligne2(x)
EndIf
If y = ligne2
*mem\b = ligne1(x)
EndIf
*mem + 1
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
ProcedureDLL SwapColumnBoardL(*board.Long, Dimx, Dimy, colonne1, colonne2); échange les colonnes colonne1 et colonne2 *board > adresse du tableau de type long
x = 0
y = 0
*mem.Long = *board.Long
Dim colonne1(Dimy)
Dim colonne2(Dimy)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
colonne1(y) = *board\l
EndIf
If x = colonne2
colonne2(y) = *board\l
EndIf
*board + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
*mem\l = colonne2(y)
EndIf
If x = colonne2
*mem\l = colonne1(y)
EndIf
*mem + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
ProcedureDLL SwapColumnBoardF(*board.Float, Dimx, Dimy, colonne1, colonne2); échange les colonnes colonne1 et colonne2 *board > adresse du tableau de type float
x = 0
y = 0
*mem.Float = *board.Float
Dim colonne1(Dimy)
Dim colonne2(Dimy)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
colonne1(y) = *board\f
EndIf
If x = colonne2
colonne2(y) = *board\f
EndIf
*board + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
*mem\f = colonne2(y)
EndIf
If x = colonne2
*mem\f = colonne1(y)
EndIf
*mem + 4
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
ProcedureDLL SwapColumnBoardW(*board.Word, Dimx, Dimy, colonne1, colonne2); échange les colonnes colonne1 et colonne2 *board > adresse du tableau de type word
x = 0
y = 0
*mem.Word = *board.Word
Dim colonne1(Dimy)
Dim colonne2(Dimy)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
colonne1(y) = *board\w
EndIf
If x = colonne2
colonne2(y) = *board\w
EndIf
*board + 2
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
*mem\w = colonne2(y)
EndIf
If x = colonne2
*mem\w = colonne1(y)
EndIf
*mem + 2
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
ProcedureDLL SwapColumnBoardB(*board.Byte, Dimx, Dimy, colonne1, colonne2); échange les colonnes colonne1 et colonne2 *board > adresse du tableau de type byte
x = 0
y = 0
*mem.Byte = *board.Byte
Dim colonne1(Dimy)
Dim colonne2(Dimy)
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
colonne1(y) = *board\b
EndIf
If x = colonne2
colonne2(y) = *board\b
EndIf
*board + 1
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
x = 0
y = 0
For i = 1 To (Dimx + 1) * (Dimy + 1)
If x = colonne1
*mem\b = colonne2(y)
EndIf
If x = colonne2
*mem\b = colonne1(y)
EndIf
*mem + 1
x = x + 1
If x = Dimx + 1
x = 0
y = y + 1
EndIf
Next
EndProcedure
; Dimx = 2
; Dimy = 4
;
; Dim tableur1.l(Dimx, Dimy)
;
; For i = 0 To Dimx
; For j = 0 To Dimy
; tableur1(i, j) = i + j + 1 ;affectation de valeurs quelconques au tableau
; Next
; Next
;
; Dim tableur2.f(Dimx, Dimy)
;
; For i = 0 To Dimx
; For j = 0 To Dimy
; tableur2(i, j) = i + j + 1 ;affectation de valeurs quelconques au tableau
; Next
; Next
;
; Dim tableur3.w(Dimx, Dimy)
;
; For i = 0 To Dimx
; For j = 0 To Dimy
; tableur3(i, j) = i + j + 1 ;affectation de valeurs quelconques au tableau
; Next
; Next
;
; Dim tableur4.b(Dimx, Dimy)
;
; For i = 0 To Dimx
; For j = 0 To Dimy
; tableur4(i, j) = Random(1) ;affectation de valeurs quelconques au tableau
; Next
; Next
;
; Debug "long"
; ShowBoardL(@tableur1(), Dimx, Dimy)
; Debug "float"
; ShowBoardF(@tableur2(), Dimx, Dimy)
; Debug "word"
; ShowBoardW(@tableur3(), Dimx, Dimy)
; Debug "byte"
; ShowBoardB(@tableur4(), Dimx, Dimy)
;
; Debug " swap line L"
; SwapLineBoardL(@tableur1(), Dimx, Dimy, 0, 1)
; Debug " swap line F"
; SwapLineBoardF(@tableur2(), Dimx, Dimy, 0, 1)
; Debug " swap line W"
; SwapLineBoardW(@tableur3(), Dimx, Dimy, 0, 1)
; Debug " swap line B"
; SwapLineBoardB(@tableur4(), Dimx, Dimy, 0, 1)
;
; Debug "long + swap line"
; ShowBoardL(@tableur1(), Dimx, Dimy)
; Debug "float + swap line"
; ShowBoardF(@tableur2(), Dimx, Dimy)
; Debug "word + swap line"
; ShowBoardW(@tableur3(), Dimx, Dimy)
; Debug "byte + swap line"
; ShowBoardB(@tableur4(), Dimx, Dimy)
;
; Debug " swap colonne L"
; SwapColumnBoardL(@tableur1(), Dimx, Dimy, 0, 1)
; Debug " swap colonne F"
; SwapColumnBoardF(@tableur2(), Dimx, Dimy, 0, 1)
; Debug " swap colonne W"
; SwapColumnBoardW(@tableur3(), Dimx, Dimy, 0, 1)
; Debug " swap colonne B"
; SwapColumnBoardB(@tableur4(), Dimx, Dimy, 0, 1)
;
; Debug "long + swap colonne"
; ShowBoardL(@tableur1(), Dimx, Dimy)
; Debug "float + swap colonne"
; ShowBoardF(@tableur2(), Dimx, Dimy)
; Debug "word + swap colonne"
; ShowBoardW(@tableur3(), Dimx, Dimy)
; Debug "byte + swap colonne"
; ShowBoardB(@tableur4(), Dimx, Dimy)
;
_lib_board