interface

Anfängerfragen zum Programmieren mit PureBasic.
delikanli_19_82
Beiträge: 173
Registriert: 30.11.2010 02:34

interface

Beitrag von delikanli_19_82 »

hallo leute,

warum will das nicht funken?

Code: Alles auswählen

Interface TableGadget
  MoveHeader( *matrix.tbl_matrix )
  GetRowIntoArrayEx2.b( *matrix.tbl_matrix, row.l, List *outkey.s(), List *outtxt.s(), List *outnbr.l() )
  GetRowIntoArrayEx.b( *matrix.tbl_matrix, row.l, List *outkey.s(), List *outtxt.s() )
...
EndInterface
PureBasic meckert bei den Zeilen, wo "List" als Parameter vorkommt. Aber die entsprechenden Prozeduren sollen mit Listenparametern umgehen können. Ich habe das ganze vorher ohne Interface als einfache Funkionen gemacht und die Tabelle hat immer funkioniert. Nun dachte ich mir, das ich das ganze in ein eigenes Objekt wie TableGadget zusammenfasse.

nun will er die Paramter nicht akzeptieren im Interface. was kann ich machen bzw. wie kann ich das trotzdem erzwingen?

mfg
kurt
Benutzeravatar
Fluid Byte
Beiträge: 3110
Registriert: 27.09.2006 22:06
Wohnort: Berlin, Mitte

Re: interface

Beitrag von Fluid Byte »

delikanli_19_82 hat geschrieben:warum will das nicht funken?
Falsche Frequenz?
Windows 10 Pro, 64-Bit / Outtakes | Derek
Benutzeravatar
hjbremer
Beiträge: 822
Registriert: 27.02.2006 22:30
Computerausstattung: von gestern
Wohnort: Neumünster

Re: interface

Beitrag von hjbremer »

Wenn das ginge, das wäre wie Ostern und Weihnachten zusammen :mrgreen:
Purebasic 5.70 x86 5.72 X 64 - Windows 10

Der Computer hat dem menschlichen Gehirn gegenüber nur einen Vorteil: Er wird benutzt
grüße hjbremer
Benutzeravatar
STARGÅTE
Kommando SG1
Beiträge: 7031
Registriert: 01.11.2005 13:34
Wohnort: Glienicke
Kontaktdaten:

Re: interface

Beitrag von STARGÅTE »

Was mit etwas wunder ist, was:
List *outtxt.s()
List *outnbr.l()
sein soll ?

Ein Pointer hat in jedem fall immer die größe eines Integers, was genau soll dann das .l oder .s ?
Ich würde es ja noch verstehen, wen du schreiben wurdest: .Long und .String, weil du dann auf die Long \l bzw den String \s des Pointers zugreifen willst.

Zum Problem selber habe ich leider keine Lösung, vermutlich geht es einfach nicht, weil es nicht vorgesehen war ...

Vermutlich wäre es einfacher eine Struktur zu erstellen, die eine Liste halt und dann deren Pointer zu übergeben:

Code: Alles auswählen

EnableExplicit

Structure Liste
  List Long.l()
EndStructure

Interface Beispiel
  Add     (*Liste.Liste)
EndInterface

Structure BeispielStructure
  *vTable
EndStructure

Procedure New()
  Protected *this.BeispielStructure
  *this = AllocateMemory(SizeOf(BeispielStructure))
  *this\vTable = ?VTable_RechnenClass
  ProcedureReturn *this
EndProcedure

Procedure Add(*This.BeispielStructure, *Liste.Liste)
  ForEach *Liste\Long()
    Debug *Liste\Long()
  Next
EndProcedure

DataSection
  VTable_RechnenClass: ; Methoden, Reihenfolge muß mit Interface übereinstimmen!
  Data.i @Add()
EndDataSection

Define *Beispiel.Beispiel
Define  Liste.Liste
AddElement(Liste\Long()) : Liste\Long() = 1
AddElement(Liste\Long()) : Liste\Long() = 2
AddElement(Liste\Long()) : Liste\Long() = 3

*Beispiel = New()
*Beispiel\Add(Liste)
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Aktuelles Projekt: Lizard - Skriptsprache für symbolische Berechnungen und mehr
delikanli_19_82
Beiträge: 173
Registriert: 30.11.2010 02:34

Re: interface

Beitrag von delikanli_19_82 »

weil man in eine Prozedurparameter normalerweise sowas schreiben kann:

Code: Alles auswählen

Procedure prozedur( list *meine_liste_n.s() )
EndProcedure
und dadurch eine externe Liste an diese Stelle verknüpften kann, dachte ich mir, das dies auch im
Interface gehen sollte.

naja. du hast ein beispiel gemacht, in der die liste über eine zwischenstruktur erreichbar gemacht wird. die methode ist mir auch klar. ich wollte eigentlich eine großteils fertige tabelle in ein objekt umwandeln, das ich zuvor aus mehreren funktionen einfach zu quick and dirty zusammengebastellt hatte, das auch funktioniert.

wer lust hat, kann sich die original code ansehen, das ich in ein objekt umwandeln will, eigentlich...:

Code: Alles auswählen

; ----------------------------------------------------------------------------- ;
; Allgemeiner Code - Dieser Teil hat noch nichts direkt mit der Tabelle zutun
; ----------------------------------------------------------------------------- ;

; Gadget Nummernzähler
Global GID.l = 0

; Liefert eine neue Gadgetnummer
Procedure.l newGID()
  Define x.l = GID
  GID = GID + 1
  ProcedureReturn x
EndProcedure

; Importiert die Schriftart mit Größe
LoadFont(0,"Arial",  12)

; ----------------------------------------------------------------------------- ;
; Die Tabelle
; ----------------------------------------------------------------------------- ;

; Leerer Image
Global empty_cell_image.l

; Temp Width
Global temporary_tbl_width.l

empty_cell_image = CreateImage(#PB_Any,1000,1000)
StartDrawing(ImageOutput(empty_cell_image))
  Box(0,0,1000,1000,RGB(255,255,255))
  For xyz = 1 To 1000 Step 5
    For zyx = 1 To 1000 Step 5
      Plot(xyz,zyx,RGB(0,0,180))
    Next
  Next
StopDrawing()

; Die Zelle
Structure tbl_cell
  col.l
  row.l
EndStructure

; Eine Zellengruppe
Structure tbl_cells
  List col.l()
  List row.l()
EndStructure

; Zellendarstellung
Structure tbl_cell_view
  x.l ; XPOS, NO YPOS, BECAUSE TOP-ALIGNMENT WILL DONE AUTOMATICALLY
  w.l ; WIDTH
  h.l ; HEIGHT
  A.b ; Activated?
EndStructure

; Die internen Daten der Tabelle
Structure tbl_matrix
  List col.l() ; Spalte
  List row.l() ; Zeile
  List gnr.l() ; Gadgetnummer einer Zelle
  List typ.b() ; 0 = Textfeld, 1 = Button, 2 = CheckBox, 3 = Bild, 4 = ComboBox
  List key.s() ; Schlüsselbegriff hinter dem Zellenwert
  List colsz.tbl_cell_view()
  List head.l(); Notiert nochmals die Gadget-Nummern der Header-Buttons
  container.l
  colwidth.l
  lineheight.l
  cols.l
  rows.l
  header.b
  number.b
  bcolor1.l
  bcolor2.l
  fcolor1.l
  fcolor2.l
  bkgcolor.l
  stylestep.b
  checkable.b
  boxheight.l
EndStructure

; Header-Buttons mit dem horizontalen Scroller bewegen
Procedure move_header( *matrix.tbl_matrix )
  Define cur_step.l = 0
  cur_step = GetGadgetAttribute( *matrix\container, #PB_ScrollArea_X )
  NewList temp.l()
  Define ww.l
  Define n.l
  ForEach *matrix\head()
    AddElement(temp())
    temp() = ww
    ww = ww + GadgetWidth(*matrix\head())
  Next
  ForEach *matrix\head()
    n = ListIndex(*matrix\head())
    SelectElement(temp(),n)
    ResizeGadget( *matrix\head(), temp()-cur_step, #PB_Ignore, #PB_Ignore, #PB_Ignore)
  Next
EndProcedure

; Ließt eine Zeile und dessen Schlüsseldaten sowie Gadget-Nummern in jeweils eigene Linked-Listen hinein
Procedure.b get_row_into_array_ex_2( *matrix.tbl_matrix, row.l, List *outkey.s(), List *outtxt.s(), List *outnbr.l() )
  ClearList(*outkey())
  ClearList(*outtxt())
  ClearList(*outnbr())
  Define x.l = 0
  Define t.b = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\key(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\row() = row
      AddElement(*outkey())
      *outkey() = Trim(*matrix\key())
      AddElement(*outtxt())
      *outtxt() = Trim(GetGadgetText(*matrix\gnr()))
      AddElement(*outnbr())
      *outnbr() = *matrix\gnr()
      t = #True 
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Ließt eine Zeile und dessen Schlüsseldaten in jeweils eigene Linked-Listen hinein
Procedure.b get_row_into_array_ex( *matrix.tbl_matrix, row.l, List *outkey.s(), List *outtxt.s() )
  ClearList(*outkey())
  ClearList(*outtxt())
  Define x.l = 0
  Define t.b = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\key(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\row() = row
      AddElement(*outkey())
      *outkey() = Trim(*matrix\key())
      AddElement(*outtxt())
      *outtxt() = Trim(GetGadgetText(*matrix\gnr()))
      t = #True 
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Ließt eine Zeile bzw. dessen Schlüsseldaten in ein Linked-List
Procedure.b get_row_into_array( *matrix.tbl_matrix, row.l, List *out.s(), ReturnKey.b = #False )
  ClearList(*out())
  Define x.l = 0
  Define t.b = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\key(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\row() = row
      AddElement(*out())
      If ReturnKey = #False
        *out() = Trim(GetGadgetText(*matrix\gnr()))
      ElseIf ReturnKey = #True
        *out() = Trim(*matrix\key())
      EndIf
      t = #True 
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Ließt eine Spalte bzw. dessen Schlüsseldaten in ein Linked-List
Procedure.b get_col_into_array( *matrix.tbl_matrix, col.l, List *out.s(), ReturnKey.b = #False )
  ClearList(*out())
  Define x.l = 0
  Define t.b = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\key(),x)
    SelectElement(*matrix\col(),x)
    If *matrix\col() = col
      AddElement(*out())
      If ReturnKey = #False
        *out() = Trim(GetGadgetText(*matrix\gnr()))
      ElseIf ReturnKey = #True
        *out() = Trim(*matrix\key())
      EndIf
      t = #True 
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Erzeugt die Tabelle
Procedure create_table( wid.l, cols.l, rows.l, *matrix.tbl_matrix, colwidth.l, lineheight.l, headers.b = #False, numbers.b = #False )
  Define cc.l
  Define rr.l
  Define nn.l
  Define wl.b = 0
  Define gimg.l = -1
  Dim px.l(cols)
  Dim pw.l(cols)
  Dim ph.l(cols)
  Define new_width.l
  For cc = 0 To cols - 1
    SelectElement(*matrix\colsz(),cc)
    If *matrix\colsz()\A <> #True
      px(cc) = cc * colwidth
      pw(cc) = colwidth - 1
      If lineheight > *matrix\colsz()\h : ph(cc) = lineheight - 1 : Else : ph(cc) = *matrix\colsz()\h : EndIf
    Else
      px(cc) = *matrix\colsz()\x
      pw(cc) = *matrix\colsz()\w
      ph(cc) = *matrix\colsz()\h
      If lineheight > *matrix\colsz()\h : ph(cc) = lineheight - 1 : Else : ph(cc) = *matrix\colsz()\h : EndIf
    EndIf
    new_width = new_width + pw(cc)
  Next
  *matrix\container = newGID()
  *matrix\colwidth = colwidth
  *matrix\lineheight = lineheight
  *matrix\cols = cols
  *matrix\rows = rows
  *matrix\header = headers
  *matrix\number =numbers
  If *matrix\bcolor1 = 0 : *matrix\bcolor1 = RGB( 255, 255, 255 ) : EndIf
  If *matrix\bcolor2 = 0 : *matrix\bcolor2 = RGB( 245, 245, 245 ) : EndIf
  If *matrix\fcolor1 = 0 : *matrix\fcolor1 = RGB(  0, 0, 160 ) : EndIf
  If *matrix\fcolor2 = 0 : *matrix\fcolor2 = RGB(  0, 150, 0 ) : EndIf
  If *matrix\bkgcolor = 0: *matrix\bkgcolor= RGB( 170, 170, 170 ) : EndIf
  Define rrr.l
  Define startpoint.l
  Define boxheight.l
  If headers = #False
    startpoint = 0
    boxheight = 0
  Else
    startpoint = 1
    boxheight = lineheight
    *matrix\boxheight = lineheight
    rr = 0
    For cc = 0 To cols - 1
      nn = newGID()
      AddElement(*matrix\col())
      AddElement(*matrix\row())
      AddElement(*matrix\gnr())
      AddElement(*matrix\key())
      *matrix\col() = cc
      *matrix\row() = rr
      *matrix\gnr() = nn
      SelectElement(*matrix\typ(),cc)
      If IsImage(gimg) > 0 
        gimg = GrabImage(empty_cell_image,#PB_Any,0,0,pw(cc),ph(cc))
      Else
        gimg = GrabImage(empty_cell_image,#PB_Any,0,0,pw(cc),ph(cc))
      EndIf
      If headers = #False 
        Select *matrix\typ()
          Case 0: StringGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess )
          Case 1: ButtonGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "...", #PB_Button_MultiLine )
          Case 2: CheckBoxGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_Checkbox_Unchecked )
          Case 3: ImageGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), ImageID(gimg) )
          Case 4: ListViewGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc) )
          Case 5: StringGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess | #PB_String_Numeric )
        EndSelect
        If IsFont(0) : SetGadgetFont(nn,FontID(0)) : EndIf
        Select wl
          Case 0
            SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor1 )
            SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor1 )
          Case 1
            SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor2 )
            SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor2 )
        EndSelect
      Else
        ButtonGadget(  nn, px(cc), rr * lineheight, pw(cc), (ph(cc)/2)+1, "" )
        AddElement(*matrix\head())
        *matrix\head() = nn
      EndIf
    Next
  EndIf
  Define HeadH.l = (ph(0)/2)+1
  If HeadH < 24 : HeadH = 24 : EndIf
  ScrollAreaGadget( *matrix\container, 0, HeadH, WindowWidth(wid), WindowHeight(wid) - HeadH, new_width, (lineheight * rows) - boxheight, 30, #PB_ScrollArea_BorderLess )
  For rrr = startpoint To rows - 1
    If headers = #False
      rr = rrr
    Else
      rr = rrr - 1
    EndIf
    For cc = 0 To cols - 1
      nn = newGID()
      AddElement(*matrix\col())
      AddElement(*matrix\row())
      AddElement(*matrix\gnr())
      *matrix\col() = cc
      *matrix\row() = rr
      *matrix\gnr() = nn
      SelectElement(*matrix\typ(),cc)
      If IsImage(gimg) > 0 
        gimg = GrabImage(empty_cell_image,#PB_Any,0,0,pw(cc),ph(cc))
      Else
        gimg = GrabImage(empty_cell_image,#PB_Any,0,0,pw(cc),ph(cc))
      EndIf
      If rr = 0
        If headers = #False 
          Select *matrix\typ()
            Case 0: StringGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess )
            Case 1: ButtonGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "...", #PB_Button_MultiLine )
            Case 2: CheckBoxGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_Checkbox_Unchecked )
            Case 3: ImageGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), ImageID(gimg) )
            Case 4: ListViewGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc) )
            Case 5: StringGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess | #PB_String_Numeric )
          EndSelect
          If IsFont(0) : SetGadgetFont(nn,FontID(0)) : EndIf
          Select wl
            Case 0
              SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor1 )
              SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor1 )
            Case 1
              SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor2 )
              SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor2 )
          EndSelect
        Else
          ButtonGadget(  nn, px(cc), rr * lineheight, pw(cc), ph(cc)+1, "" )
        EndIf
      Else
        If numbers = #False
          Select *matrix\typ()
            Case 0: StringGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess )
            Case 1: ButtonGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "...", #PB_Button_MultiLine )
            Case 2: CheckBoxGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_Checkbox_Unchecked )
            Case 3: ImageGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), ImageID(gimg) )
            Case 4: ListViewGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc) )
          EndSelect
          If IsFont(0) : SetGadgetFont(nn,FontID(0)) : EndIf
          Select wl
            Case 0
              SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor1 )
              SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor1 )
            Case 1
              SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor2 )
              SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor2 )
          EndSelect
        Else
          If cc = 0
            If *matrix\checkable = #False
              ButtonGadget(  nn, px(cc), rr * lineheight, pw(cc)+1, ph(cc)+1, Str(rr) )
            Else
              ButtonGadget(  nn, px(cc), rr * lineheight, pw(cc)+1, ph(cc)+1, Str(rr), #PB_Button_Toggle )
            EndIf
          Else
            Select *matrix\typ()
              Case 0: StringGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess )
              Case 1: ButtonGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "...", #PB_Button_MultiLine )
              Case 2: CheckBoxGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_Checkbox_Unchecked )
              Case 3: ImageGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), ImageID(gimg) )
              Case 4: ListViewGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc) )
              Case 5: StringGadget( nn, px(cc), rr * lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess | #PB_String_Numeric )
            EndSelect
            If IsFont(0) And IsGadget(nn) : SetGadgetFont(nn,FontID(0)) : EndIf
            Select wl
              Case 0
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor1 ) : EndIf
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor1 ) : EndIf
              Case 1
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor2 ) : EndIf
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor2 ) : EndIf
            EndSelect            
          EndIf
        EndIf
      EndIf
    Next
    If wl = 0 : wl = 1 : ElseIf wl = 1 : wl = 0 : EndIf
  Next
  CloseGadgetList()
  SetGadgetColor( *matrix\container, #PB_Gadget_BackColor, *matrix\bkgcolor )
  *matrix\stylestep = wl
EndProcedure

; ComboBox-Element füllen
Procedure.b fill_combo_cell( *matrix.tbl_matrix, row.l, col.l, List *entries.s(), default_value.s = "<none>" )
  Define x.l = 0 : Define success.l = #False
  Define ee.l = -1
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\col() = col And *matrix\row() = row
      ee = *matrix\gnr()
      success = #True
      Break
    EndIf
  Next
  If ee > -1
    ForEach *entries()
      AddGadgetItem( ee, 0, *entries() )
    Next
  EndIf
  If default_value <> "<none>"
    SetGadgetText(*matrix\gnr(),default_value)
  EndIf
  ProcedureReturn success
EndProcedure

; Schreibt in die Zelle
Procedure.b set_cell( *matrix.tbl_matrix, row.l, col.l, value.s )
  Define x.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\col() = col And *matrix\row() = row
      SetGadgetText( *matrix\gnr(),value)
      success = #True
      Break
    EndIf
  Next
  ProcedureReturn success
EndProcedure

; Schreibt in die Zellenschlüssel
Procedure.b set_cell_key( *matrix.tbl_matrix, row.l, col.l, value.s )
  Define x.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    SelectElement(*matrix\key(),x)
    If *matrix\col() = col And *matrix\row() = row
      *matrix\key() = value
      success = #True
      Break
    EndIf
  Next
  ProcedureReturn success
EndProcedure

; Ließt aus der Zelle
Procedure.s get_cell( *matrix.tbl_matrix, row.l, col.l )
  Define x.l = 0
  Define t.s = ""
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\col() = col And *matrix\row() = row
      t = GetGadgetText( *matrix\gnr())
      Break
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Ließt aus dem Zellenschlüssel
Procedure.s get_cell_key( *matrix.tbl_matrix, row.l, col.l )
  Define x.l = 0
  Define t.s = ""
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    SelectElement(*matrix\key(),x)
    If *matrix\col() = col And *matrix\row() = row
      t = *matrix\key()
      Break
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Ließt aus der Zelle
Procedure.l get_cell_element( *matrix.tbl_matrix, row.l, col.l )
  Define x.l = 0
  Define t.l = -1
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\col() = col And *matrix\row() = row
      t = *matrix\gnr()
      Break
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Ändert den Status einer Zelle
Procedure.b set_state( *matrix.tbl_matrix, row.l, col.l, value.l )
  Define x.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\col() = col And *matrix\row() = row
      SetGadgetState( *matrix\gnr(),value)
      success = #True
      Break
    EndIf
  Next
  ProcedureReturn success
EndProcedure

; Ließt den Status einer Zelle
Procedure.l get_state( *matrix.tbl_matrix, row.l, col.l )
  Define x.l = 0
  Define t.l = 0
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\col() = col And *matrix\row() = row
      t = GetGadgetState( *matrix\gnr())
      Break
    EndIf
  Next
  ProcedureReturn t
EndProcedure

; Leert alle Zellen
Procedure clear_cells( *matrix.tbl_matrix )
  Define x.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
      x = ListIndex(*matrix\gnr())
      SelectElement(*matrix\row(),x)
      SelectElement(*matrix\col(),x)
      If *matrix\header = #False 
        If IsGadget(*matrix\gnr()) : SetGadgetText( *matrix\gnr(),"") : EndIf
      Else
        If *matrix\number = #False 
          If *matrix\row() > 0 
            If IsGadget(*matrix\gnr()) : SetGadgetText( *matrix\gnr(),"") : EndIf
          EndIf
        Else
          If *matrix\row() > 0 And *matrix\col() > 0
            If IsGadget(*matrix\gnr()) : SetGadgetText( *matrix\gnr(),"") : EndIf
          EndIf        
        EndIf
      EndIf
  Next
EndProcedure

; Löscht alle Zeilen bis auf den Header, falls dieser verfügbar ist
Procedure clear_table( *matrix.tbl_matrix );???
  ForEach *matrix\gnr()
    FreeGadget(*matrix\gnr())
  Next
  FreeGadget(*matrix\container)
  ClearList(*matrix\gnr())
  ClearList(*matrix\col())
  ClearList(*matrix\row())
  ClearList(*matrix\key())
  ClearList(*matrix\head())
EndProcedure

; Ändert die Länge einer Spalte
Procedure set_col_width( *matrix.tbl_matrix, col.l, sz.l )
  If col = 0 : temporary_tbl_width = 0 : EndIf
  If ListSize(*matrix\colsz()) < col + 1: AddElement(*matrix\colsz()) : EndIf
  SelectElement(*matrix\colsz(),col)
  *matrix\colsz()\A = #True
  *matrix\colsz()\x = temporary_tbl_width
  *matrix\colsz()\w = sz
  temporary_tbl_width = temporary_tbl_width + sz
  ;Debug "X=" + Str(*matrix\colsz()\x) + ", W=" + Str(sz) + ", N=" + Str(temporary_tbl_width)
EndProcedure

; Ändert die Breite einer Zeile
Procedure set_row_height( *matrix.tbl_matrix, row.l, sz.l )
  If ListSize(*matrix\colsz()) < col + 1 : AddElement(*matrix\colsz()) : EndIf
  *matrix\colsz()\A = #True
  SelectElement(*matrix\colsz(),col)
  *matrix\colsz()\h = sz
EndProcedure

; Liefert die Zelle, auf dem ein Ereignis ausgelöst wird und #True
; Wenn kein Ereignis auf der Tabelle abgefangen wird, kommt #False
Procedure.b event_cell( *matrix.tbl_matrix, *cell.tbl_cell, e.l )
  Define x.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\gnr() = e
      *cell\col = *matrix\col()
      *cell\row = *matrix\row()
      success = #True
      Break
    EndIf
  Next
  ProcedureReturn success
EndProcedure

; Überprüft, ob auf einer Spalte derselbe Wert mehr als einmal vorkommt.
; Liefert die Menge der Vormmen
Procedure.l check_col_value_total( *matrix.tbl_matrix, col.l, value.s, look_in_key.b = #False )
  Define x.l
  Define n.l = 0
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\row(),x)
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\key(),x)
    If *matrix\col() = col
      If look_in_key = #False And GetGadgetText(*matrix\gnr()) = value Or look_in_key = #False Or LCase(GetGadgetText(*matrix\gnr())) = LCase(value) Or look_in_key = #True And *matrix\key() = value Or look_in_key = #True Or LCase(*matrix\key()) = LCase(value)
        n = n + 1
      EndIf
    EndIf
  Next
  ProcedureReturn n
EndProcedure

; Überprüft voll automatisch, ob irgendwelche Werte mehrmals auf derselben Spalte vorkommen.
; Lieferft die Zeile des ersten betroffenen Werts bei key oder den GID beim Zellenelement, das mehrmals vorkommt.
Procedure.l check_col_auto_copies( *matrix.tbl_matrix, col.l, ignore_checked_on_col.l = -1, no_empty.b = #False, look_in_key.b = #False )
  Define x.l
  Define n.l = 0
  Define p.l = -1
  Define value.s
  Define checks.b = #False
  Define chpos.l = 0
  NewList lnum.l()
  NewList cval.s()
  NewList chek.l()
  If ignore_checked_on_col > -1
    ForEach *matrix\gnr()
      x = ListIndex(*matrix\gnr())
      SelectElement(*matrix\col(),x)
      If *matrix\col() = ignore_checked_on_col
        AddElement(chek())
        chek() = GetGadgetState(*matrix\gnr())
        checks = #True
      EndIf
    Next
  EndIf
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\row(),x)
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\key(),x)
    If *matrix\col() = col
      If ignore_checked_on_col > -1
        If checks = #False 
          If look_in_key = #False
            If no_empty = #False
              AddElement(cval()) : cval() = GetGadgetText(*matrix\gnr())
              AddElement(lnum()) : lnum() = *matrix\gnr()
            Else
              If GetGadgetText(*matrix\gnr()) <> ""
                AddElement(cval()) : cval() = GetGadgetText(*matrix\gnr())
                AddElement(lnum()) : lnum() = *matrix\gnr()
              EndIf
            EndIf
          ElseIf look_in_key = #True
            If no_empty = #False
              AddElement(cval()) : cval() = *matrix\key()
              AddElement(lnum()) : lnum() = *matrix\row()
            Else
              If *matrix\key() <> ""
                AddElement(cval()) : cval() = *matrix\key()
                AddElement(lnum()) : lnum() = *matrix\row()
              EndIf
            EndIf
          EndIf
        ElseIf checks = #True
          SelectElement(chek(),chpos)
          chpos = chpos + 1
          If chek() = 0 ; WENN 1, DANN WIRD HALT IGNORIERT
            If look_in_key = #False
              If no_empty = #False
                AddElement(cval()) : cval() = GetGadgetText(*matrix\gnr())
                AddElement(lnum()) : lnum() = *matrix\gnr()
              Else
                If GetGadgetText(*matrix\gnr()) <> ""
                  AddElement(cval()) : cval() = GetGadgetText(*matrix\gnr())
                  AddElement(lnum()) : lnum() = *matrix\gnr()
                EndIf
              EndIf
            ElseIf look_in_key = #True
              If no_empty = #False
                AddElement(cval()) : cval() = *matrix\key()
                AddElement(lnum()) : lnum() = *matrix\row()
              Else
                If *matrix\key() <> ""
                  AddElement(cval()) : cval() = *matrix\key()
                  AddElement(lnum()) : lnum() = *matrix\row()
                EndIf
              EndIf
            EndIf
          EndIf
        EndIf
      Else
        If look_in_key = #False
          If no_empty = #False
            AddElement(cval()) : cval() = GetGadgetText(*matrix\gnr())
            AddElement(lnum()) : lnum() = *matrix\gnr()
          Else
            If GetGadgetText(*matrix\gnr()) <> ""
              AddElement(cval()) : cval() = GetGadgetText(*matrix\gnr())
              AddElement(lnum()) : lnum() = *matrix\gnr()
            EndIf
          EndIf
        ElseIf look_in_key = #True
          If no_empty = #False
            AddElement(cval()) : cval() = *matrix\key()
            AddElement(lnum()) : lnum() = *matrix\row()
          Else
            If *matrix\key() <> ""
              AddElement(cval()) : cval() = *matrix\key()
              AddElement(lnum()) : lnum() = *matrix\row()
            EndIf
          EndIf
        EndIf
      EndIf
    EndIf
  Next
  ForEach cval()
    n = check_col_value_total( *matrix, col, cval(), look_in_key )
    If n > 1
      SelectElement(lnum(),ListIndex(cval()))
      p = lnum()
      Break
    EndIf
  Next
  ProcedureReturn p
EndProcedure

; Leergelassene Felder ausspühren und den ersten gefunden mit der Zeilennummer.
; Ignoriert aber Zeilen, die bei Spalte ignore_checked_on_col State = 1 haben.
; Die Spalte ignore_checked_on_col wird nur dann berücksichtigt, wenn dessen Wert über -1 liegt.
Procedure.l check_col_for_empty_fields( *matrix.tbl_matrix, col.l, ignore_checked_on_col.l = -1 )
  Define x.l
  Define n.l = -1
  Define rr.l = 0
  Define ignore_me.b = #False
  If *matrix\header = #True : rr = 1 : EndIf
  NewList tnr.l()
  ForEach *matrix\gnr()
    AddElement(tnr())
    tnr() = *matrix\gnr()
  Next
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\row(),x)
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\key(),x)
    If *matrix\col() = col And *matrix\row() >= rr
      ignore_me = #False
      If GetGadgetText(*matrix\gnr()) = ""
        n = *matrix\row()
        If ignore_checked_on_col > -1
          ForEach *matrix\row()
            If *matrix\row() >= rr
              SelectElement(*matrix\col(),ListIndex(*matrix\row()))
              If *matrix\col() = ignore_checked_on_col
                SelectElement(tnr(),ListIndex(*matrix\row()))
                If GetGadgetState(tnr()) = 1
                  ignore_me = #True
                  Break
                EndIf
              EndIf
            EndIf
          Next
        EndIf
        If ignore_me = #False
          Break
        Else
          n = -1
          ignore_me = #False
        EndIf
      EndIf
    EndIf
  Next
  ProcedureReturn n
EndProcedure

; Fügt eine Zeile am Ende der Tabelle
Procedure.b add_row( *matrix.tbl_matrix )
  Define cc.l
  Define rr.l : Define rrr.l
  Define nn.l
  Define gimg.l = -1
  Dim px.l(*matrix\cols)
  Dim pw.l(*matrix\cols)
  Dim ph.l(*matrix\cols)
  For cc = 0 To *matrix\cols - 1
    SelectElement(*matrix\colsz(),cc)
    If *matrix\colsz()\A <> #True
      px(cc) = cc * *matrix\colwidth
      pw(cc) = *matrix\colwidth - 1
      If *matrix\lineheight > *matrix\colsz()\h : ph(cc) = *matrix\lineheight - 1 : Else : ph(cc) = *matrix\colsz()\h : EndIf
    Else
      px(cc) = *matrix\colsz()\x
      pw(cc) = *matrix\colsz()\w -1
      ph(cc) = *matrix\colsz()\h
      If *matrix\lineheight > *matrix\colsz()\h : ph(cc) = *matrix\lineheight - 1 : Else : ph(cc) = *matrix\colsz()\h : EndIf
    EndIf
  Next
  LastElement(*matrix\col())
  LastElement(*matrix\row())
  LastElement(*matrix\gnr())
  LastElement(*matrix\key())
  rr = *matrix\rows
  rrr = rr
  If *matrix\header = #True : rrr = rrr - 1 : EndIf
  *matrix\rows = *matrix\rows + 1
  OpenGadgetList(*matrix\container)
  For cc = 0 To *matrix\cols - 1
      nn = newGID()
      AddElement(*matrix\col())
      AddElement(*matrix\row())
      AddElement(*matrix\gnr())
      AddElement(*matrix\key())
      *matrix\col() = cc
      *matrix\row() = rr
      *matrix\gnr() = nn
      SelectElement(*matrix\typ(),cc)
      If IsImage(gimg) > 0 
        gimg = GrabImage(empty_cell_image,#PB_Any,0,0,pw(cc),ph(cc))
      Else
        gimg = GrabImage(empty_cell_image,#PB_Any,0,0,pw(cc),ph(cc))
      EndIf
      If *matrix\number = #False
        ;StringGadget( nn, px(cc), rr * *matrix\lineheight, pw(cc), ph(cc),"", #PB_String_BorderLess )
        Select *matrix\typ()
          Case 0: StringGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess )
          Case 1: ButtonGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), "...", #PB_Button_MultiLine )
          Case 2: CheckBoxGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), "", #PB_Checkbox_Unchecked )
          Case 3: ImageGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), ImageID(gimg) )
          Case 4: ListViewGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc) )
          Case 5: StringGadget( nn, px(cc), rr * *matrix\lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess | #PB_String_Numeric )
        EndSelect
        If IsFont(0) : SetGadgetFont(nn,FontID(0)) : EndIf
        Select *matrix\stylestep
          Case 0
            If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor1 ) : EndIf
            If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor1 ) : EndIf
          Case 1
            If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor2 ) : EndIf
            If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor2 ) : EndIf
        EndSelect
      Else
        If cc = 0
          If *matrix\checkable = #False
            ButtonGadget(  nn, px(cc), rrr * *matrix\lineheight, pw(cc)+1, ph(cc)+1, Str(rr) )
          Else
            ButtonGadget(  nn, px(cc), rrr * *matrix\lineheight, pw(cc)+1, ph(cc)+1, Str(rr), #PB_Button_Toggle )
          EndIf
        Else
          ;If IsGadget(nn) > 0
            Select *matrix\typ()
              Case 0: StringGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess )
              Case 1: ButtonGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), "...", #PB_Button_MultiLine )
              Case 2: CheckBoxGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), "", #PB_Checkbox_Unchecked )
              Case 3: ImageGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc), ImageID(gimg) )
              Case 4: ListViewGadget( nn, px(cc), rrr * *matrix\lineheight, pw(cc), ph(cc) )
              Case 5: StringGadget( nn, px(cc), rr * *matrix\lineheight, pw(cc), ph(cc), "", #PB_String_BorderLess | #PB_String_Numeric )
            EndSelect
            If IsFont(0) : SetGadgetFont(nn,FontID(0)) : EndIf
            Select *matrix\stylestep
              Case 0
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor1 ) : EndIf
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor1 ) : EndIf
              Case 1
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_BackColor, *matrix\bcolor2 ) : EndIf
                If IsGadget(nn) > 0 : SetGadgetColor( nn, #PB_Gadget_FrontColor, *matrix\fcolor2 ) : EndIf
            EndSelect
          ;EndIf
        EndIf
      EndIf
      ;px(cc) = *matrix\cpx();px(cc) + *matrix\cwd() ;+ 2
  Next
  CloseGadgetList()
  SetGadgetAttribute( *matrix\container, #PB_ScrollArea_InnerHeight, GetGadgetAttribute(*matrix\container,#PB_ScrollArea_InnerHeight) + *matrix\lineheight )
  If *matrix\stylestep = 0 : *matrix\stylestep = 1 : ElseIf *matrix\stylestep = 1 : *matrix\stylestep = 0 : EndIf    
EndProcedure

; Liefert die Elemente einer Zeile zurück
Procedure.b get_row_elements( *matrix.tbl_matrix, lnr.l, List *out.l() )
  Define n.l = - 1
  Define p.l
  Define bb.b = #False
  Define ll.l = lnr
  Define restart.b = #False
  ForEach *matrix\gnr()
    p = ListIndex(*matrix\gnr())
    SelectElement(*matrix\row(),p)
    If *matrix\row() = ll
      If *matrix\gnr() = -1
        ll = ll + 1
      Else
        AddElement(*out())
        *out() = *matrix\gnr()
        bb = #True
      EndIf
    EndIf
  Next
  ProcedureReturn bb
EndProcedure

; Verschiebt eine Zeile nach oben
Procedure move_row_up( *matrix.tbl_matrix, lnr.l )
    NewList ThisLn.l()
    NewList NextLn.l()
    Define nl.b = 0
    ; Elemente der aktuell markierten Zeile
    get_row_elements( *matrix, lnr, ThisLn() )
    ; Elemente der nächsten Zeile, falls sie existiert
    If get_row_elements( *matrix, lnr + 1, NextLn() ) = #True
      ForEach ThisLn()
        n = ListIndex(ThisLn())
        SelectElement(NextLn(),n)
        ; Die Y-Werte des This*, in die der Next* schreiben
        If nl = 0
          ResizeGadget( NextLn(), #PB_Ignore, GadgetY(ThisLn()) + GadgetHeight(ThisLn()), #PB_Ignore, GadgetHeight(ThisLn()) )
          nl = 1
        Else
          ResizeGadget( NextLn(), #PB_Ignore, GadgetY(ThisLn()) + GadgetHeight(ThisLn()) + 1, #PB_Ignore, GadgetHeight(ThisLn()) )
        EndIf
      Next
    EndIf
EndProcedure

; Löscht die aktuelle Zeile
Procedure.b remove_row( *matrix.tbl_matrix, lnr.l )
  ; WENN HEADER VERFÜGBAR UND MARKIERT, DANN KEINE LÖSCHUNG
  Define n.l = 0 : Define m.l = 0
  Define conti.b = #False 
  If *matrix\header = #False
    If lnr < 1
      ProcedureReturn #False
    Else
      If lnr > *matrix\rows - 1
        ProcedureReturn #False
      Else
        conti = #True 
      EndIf
    EndIf
  Else
    If lnr < 0
      ProcedureReturn #False
    Else
      If lnr > *matrix\rows - 1
        ProcedureReturn #False
      Else
        conti = #True 
      EndIf
    EndIf
  EndIf
  If conti = #True
    NewList ThisLn.l()
    NewList NextLn.l()
    ; Elemente der zu löschenden Zeile
    get_row_elements( *matrix, lnr, ThisLn() )
    ; Elemente der nächsten Zeile, falls sie existiert
    If get_row_elements( *matrix, lnr + 1, NextLn() ) = #True
      ForEach ThisLn()
        n = ListIndex(ThisLn())
        SelectElement(NextLn(),n)
        ; Die Y-Werte des This*, in die der Next* schreiben
        ResizeGadget( NextLn(), #PB_Ignore, GadgetY(ThisLn()), #PB_Ignore, #PB_Ignore )
        ; This* Element löschen
        FreeGadget( ThisLn() )
      Next
      ; Anschließend werden bei *matrix\gnr(), die gelöschten Elemente zu -1 abgeändert
      ;ForEach *matrix\gnr()
      ;  n = ListIndex(*matrix\gnr())
      ;  SelectElement(*matrix\col(),n)
      ;  SelectElement(*matrix\row(),n)
      ;  If *matrix\row() = lnr
      ;    *matrix\gnr() = -1
      ;    *matrix\col() = -1
      ;    *matrix\row() = -1
      ;  EndIf
      ;Next
      ForEach *matrix\gnr()
        n = ListIndex(*matrix\gnr())
        SelectElement(*matrix\col(),n)
        SelectElement(*matrix\row(),n)
        SelectElement(*matrix\typ(),n)
        SelectElement(*matrix\key(),n)
        If *matrix\row() = lnr
          DeleteElement(*matrix\gnr())
          DeleteElement(*matrix\col())
          DeleteElement(*matrix\row())
          DeleteElement(*matrix\typ())
          DeleteElement(*matrix\key())
        EndIf
      Next
      ; Schließlich werden alle anderen Elementzeilen nach oben verschoben
      For n = lnr + 1 To *matrix\rows - 1
        move_row_up( *matrix, n )
      Next
      *matrix\rows = *matrix\rows - 1
    Else
      ForEach ThisLn()
        ; This* Element löschen
        FreeGadget( ThisLn() )
      Next
      ; Anschließend werden bei *matrix\gnr(), die gelöschten Elemente zu -1 abgeändert
      ;ForEach *matrix\gnr()
      ;  n = ListIndex(*matrix\gnr())
      ;  SelectElement(*matrix\col(),n)
      ;  SelectElement(*matrix\row(),n)
      ;  If *matrix\row() = lnr
      ;    *matrix\gnr() = -1
      ;    *matrix\col() = -1
      ;    *matrix\row() = -1
      ;  EndIf
      ;Next
      ForEach *matrix\gnr()
        n = ListIndex(*matrix\gnr())
        SelectElement(*matrix\col(),n)
        SelectElement(*matrix\row(),n)
        SelectElement(*matrix\typ(),n)
        SelectElement(*matrix\key(),n)
        If *matrix\row() = lnr
          DeleteElement(*matrix\gnr())
          DeleteElement(*matrix\col())
          DeleteElement(*matrix\row())
          DeleteElement(*matrix\typ())
          DeleteElement(*matrix\key())
        EndIf
      Next
    EndIf
    ProcedureReturn #True
  EndIf
EndProcedure

; Entfernt markierte Zeilen
Procedure remove_checked_rows( *matrix.tbl_matrix, col.l )
  NewList marks.s()
  Define n.l
  Define x.l = 0
  Define t.l = 0
  ForEach *matrix\gnr()
    x = ListIndex(*matrix\gnr())
    SelectElement(*matrix\col(),x)
    SelectElement(*matrix\row(),x)
    If *matrix\col() = col
      If GetGadgetState( *matrix\gnr()) = 1
        AddElement(marks())
        marks() = GetGadgetText(*matrix\gnr())
      EndIf
    EndIf
  Next
  ForEach marks()
    ForEach *matrix\gnr()
      If GetGadgetText(*matrix\gnr()) = marks()
        SelectElement(*matrix\row(),ListIndex(*matrix\gnr()))
        remove_row(*matrix,*matrix\row())
      EndIf
    Next
  Next
EndProcedure

; Liefert die Zelle mit der Position-Index, des gesuchten Eintrags
Procedure.b find_cell( *matrix.tbl_matrix, *cell.tbl_cell, value.s, index.l = 0 )
  Define x.l = 0 : Define n.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
      x = ListIndex(*matrix\gnr())
      SelectElement(*matrix\row(),x)
      SelectElement(*matrix\col(),x)
      If IsGadget(*matrix\gnr())
        If GetGadgetText(*matrix\gnr()) = value.s Or LCase(GetGadgetText(*matrix\gnr())) = LCase(value.s)
          If n = index
            *cell\col = *matrix\col()
            *cell\row = *matrix\row()
            success = #True
          Else
            n = n + 1
          EndIf
          Break
        EndIf
      EndIf
  Next
  ProcedureReturn success
EndProcedure

; Liefert alle Zellen mit dem gesuchten Eintrag
Procedure.b find_cells( *matrix.tbl_matrix, *cell.tbl_cells, value.s )
  Define x.l = 0 : Define success.l = #False
  ClearList(*cell\col())
  ClearList(*cell\row())
  ForEach *matrix\gnr()
      x = ListIndex(*matrix\gnr())
      SelectElement(*matrix\row(),x)
      SelectElement(*matrix\col(),x)
      If GetGadgetText(*matrix\gnr()) = value.s Or LCase(GetGadgetText(*matrix\gnr())) = LCase(value.s)
        AddElement(*cell\col())
        AddElement(*cell\row())
        *cell\col() = *matrix\col()
        *cell\row() = *matrix\row()
        success = #True
        Break
      EndIf
  Next
  ProcedureReturn success
EndProcedure

; Ließt eine Spalte in eine Array-Liste
Procedure.b export_column( *matrix.tbl_matrix, List *output.s(), col.l )
  Define x.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
      x = ListIndex(*matrix\gnr())
      SelectElement(*matrix\row(),x)
      SelectElement(*matrix\col(),x)
      If *matrix\col() = col
        AddElement(*output())
        *output() = GetGadgetText(*matrix\gnr())
      EndIf
  Next
  ProcedureReturn success
EndProcedure

; Ließt eine Array-Liste in eine Spalte, aber nur soviel
Procedure.b import_column( *matrix.tbl_matrix, List *source.s(), col.l );???
  
EndProcedure

; Ließt eine Spalte in eine Array-Liste
Procedure.b export_row( *matrix.tbl_matrix, List *output.s(), row.l )
  Define x.l = 0 : Define success.l = #False
  ForEach *matrix\gnr()
      x = ListIndex(*matrix\gnr())
      SelectElement(*matrix\row(),x)
      SelectElement(*matrix\col(),x)
      If *matrix\row() = row
        AddElement(*output())
        *output() = GetGadgetText(*matrix\gnr())
      EndIf
  Next
  ProcedureReturn success
EndProcedure

; Ließt eine Array-Liste in eine Spalte, aber nur soviel
Procedure.b import_row( *matrix.tbl_matrix, List *source.s(), row.l );???
  
EndProcedure

; Fügt eine Spalte am äußersten rechten Rand hinzu
Procedure.b add_col( *matrix.tbl_matrix );???
EndProcedure

; Löscht die aktuelle Spalte
Procedure.b remove_col( *matrix.tbl_matrix, cnr.l );???
EndProcedure

; Fügt einer Spalte, ein besimmtes Typ zu
Procedure set_col_type( *matrix.tbl_matrix, col.l, col_type_def.l = 0 )
  AddElement(*matrix\typ())
  *matrix\typ() = col_type_def
EndProcedure

das ist keine superlösung für eine tabelle, aber ein erster ansatz für zumindest kleine dinge.

naja, wers eben will.

danke für eure tipps..

mfg

kurt
Antworten