lib tableau

Vous avez une idée pour améliorer ou modifier PureBasic ? N'hésitez pas à la proposer.
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

lib tableau

Message par graph100 »

je n'ai trouver personne qui l a fais
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)
; 
et la lib deja compilée

_lib_board
Dr. Dri
Messages : 2527
Inscription : ven. 23/janv./2004 18:10

Message par Dr. Dri »

Parmi les nouveautés de la version 4, il y a le mot clé Swap. J'ai pas regardé ton code en détail mais parmi les nouveautés de la V4 il y a aussi le passage de tableau en paramètre. Ca peut peut etre pas mal simplifier ton code...

Dri
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Message par comtois »

ça ne devrait pas être dans le forum "trucs et astuces" ?
http://purebasic.developpez.com/
Je ne réponds à aucune question technique en PV, utilisez le forum, il est fait pour ça, et la réponse peut profiter à tous.
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Message par graph100 »

y a pas un moyen de faire la meme chose avec les chaines ?

je l'ai fait avec le tuto de Torp sur les pointeur et je ne compren pas ca :

Code : Tout sélectionner

*pointeur + 4
qui fait avence l'adresse de 4 octets ?
on devrait pas faire

Code : Tout sélectionner

*pointeur = *pointeur + 4
[/code]
Good07
Messages : 308
Inscription : ven. 23/avr./2004 18:08
Localisation : Hérault 34190 Laroque

Message par Good07 »

Bonsoir graph100.

Pour les pointeurs je ne serai pas affirmatif, puisque je ne m'en sert pas. Mais si c'est identique aux variables tu as deux façons de l'écrire pour des résultats identiques.

Par exemple:

Po=Po+1 ou tout simplement Po+1 donne le même résultat.

Voilà voilà.
lionel_om
Messages : 1500
Inscription : jeu. 25/mars/2004 11:23
Localisation : Sophia Antipolis (Nice)
Contact :

Message par lionel_om »

graph100 a écrit :

Code : Tout sélectionner

*pointeur + 4
Cette instruction te fait incrémenter de 4 octets ton pointeurs.

Par exemple, s'il pointe sur une cellule d'un tableau d'entiers (long), tu te retrouve à la case suivante. Cela t'évite d'utiliser les paranthèses pour accéder à un indice précis. Ca doit être un moyen plus rapide de parcourir les données d'un tableau.

Exemple (non testé) :

Code : Tout sélectionner

#TAILLE = 10
Dim Tab.l(#TAILLE)
for i = 0 to #Taille-1
  Tab(i) = i+1
next

*ptr.Long = @Tab()
While *ptr\l <> #Taille
  Debug *ptr\l
  *ptr + sizeof(Long)
wend
Lio
Webmestre de Basic-univers
Participez à son extension: ajouter vos programmes et partagez vos codes !
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Message par graph100 »

Good07 a écrit : Mais si c'est identique aux variables tu as deux façons de l'écrire pour des résultats identiques.

Par exemple:

Po=Po+1 ou tout simplement Po+1 donne le même résultat.

Voilà voilà.
je ne savais on en apprend tout les jours !

@lionel_om

ton code marche aussi avec les chaines
je ne savais pas que la taille de la structure string changer en fonction de la derniere variable string utilise (d apres ce que j'ai compris ?)
lionel_om
Messages : 1500
Inscription : jeu. 25/mars/2004 11:23
Localisation : Sophia Antipolis (Nice)
Contact :

Message par lionel_om »

graph100 a écrit :je ne savais pas que la taille de la structure string changer en fonction de la derniere variable string utilise (d apres ce que j'ai compris ?)
dsl je ne comprend pas ta question... :?

Par contre pour ma boucle "While" (dans l'exemple) je m'arrete qd je trouve la valeur 10 (parce que j'ai rempli mon tableau de 1 à 10. Mais dans un parcours plus général, faudrait une boucle "for" ou s'arrêté qd le pointeur à atteint la valeur : AdresseDuTableau + tailleTableau * sizeof(Struct).

Code : Tout sélectionner

*ptr.Long = @Tab()
While *ptr\l <> #Taille * sizeof(l) + @Tab()
  Debug *ptr\l
  *ptr + sizeof(Long)
wend
Webmestre de Basic-univers
Participez à son extension: ajouter vos programmes et partagez vos codes !
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Message par graph100 »

je veus dire que si tu utilise une variable string mavariable.s = "text"
sizeof(string) renvera "4" puis juste apre tu utilise une variable string tavariable.s = "mon text" sizeof(string) renvera 8

la meme lib avec les tableaus de string

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

Procedure ShowBoardS(*board.String, 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 + "  |  " + *board\s
    
    *board + SizeOf(String)
    
    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 SwapLineBoardS(*board.String, Dimx, Dimy, ligne1, ligne2); échange les lignes ligne1 et ligne2  *board > adresse du tableau de type string
  x = 0
  y = 0
  
  *mem.String = *board.String
  
  Dim lignea.s(Dimx)
  Dim ligneb.s(Dimx)
  
  For i = 1 To (Dimx + 1) * (Dimy + 1)
    If y = ligne1
      lignea(x) = *board\s
    EndIf
    
    If y = ligne2
      ligneb(x) = *board\s
    EndIf
    
    *board + SizeOf(String)
    
    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\s = ligneb(x)
    EndIf
    
    If y = ligne2
      *mem\s = lignea(x)
    EndIf
    
    *mem + SizeOf(String)
    
    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

ProcedureDLL SwapColumnBoardS(*board.String, Dimx, Dimy, colonne1, colonne2); échange les colonnes colonne1 et colonne2  *board > adresse du tableau de type string
  x = 0
  y = 0
  
  *mem.String = *board.String
  
  Dim colonnea.s(Dimy)
  Dim colonneb.s(Dimy)
  
  For i = 1 To (Dimx + 1) * (Dimy + 1)
    If x = colonne1
      colonnea(y) = *board\s
    EndIf
    
    If x = colonne2
      colonneb(y) = *board\s
    EndIf
    
    *board + SizeOf(String)
    
    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\s = colonneb(y)
    EndIf
    
    If x = colonne2
      *mem\s = colonnea(y)
    EndIf
    
    *mem + SizeOf(String)
    
    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 
; 
; Dim tableur5.s(Dimx, Dimy)
; 
; For i = 0 To Dimx
;   For j = 0 To Dimy
;     tableur5(i, j) = Chr(65 + i + j) + Chr(Random(255)) ;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 "string"
; ShowBoardS(@tableur5(), 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 " swap line S"
; SwapLineBoardS(@tableur5(), 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 "string + swap line"
; ShowBoardS(@tableur5(), 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 S"
; SwapColumnBoardS(@tableur5(), 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)
; Debug "string + swap colonne"
; ShowBoardS(@tableur5(), Dimx, Dimy)
; 
Répondre