DIM Tabelle, was mache ich falsch?

Previous topic - Next topic

Veritas

Code (glbasic) Select
DIM Position[10] [1]

Position [1] [0] = 50
Position [1] [1] = 0
Position [2] [0] = 350
Position [2] [1] = 0
Position [3] [0] = 50
Position [3] [1] = 100
Position [4] [0] = 350
Position [4] [1] = 100
Position [5] [0] = 50
Position [5] [1] = 200
Position [6] [0] = 350
Position [6] [1] = 200
Position [7] [0] = 50
Position [7] [1] = 300
Position [8] [0] = 350
Position [8] [1] = 300
Position [9] [0] = 50
Position [9] [1] = 400

FOR x=1 TO 9

DRAWRECT Position [x] [0], Position [x] [1], 200, 50, Farbe

NEXT

SHOWSCREEN
WEND
QuoteC:\DOKUME~1\Nico\LOKALE~1\Temp\glbasic\gpc_temp0.cpp:51: error: `(&__GLBASIC__::Position)->__GLBASIC__::DGIntArray::operator()(#`fix_trunc_expr' not supported by dump_expr#, 0, 0, 0)' cannot be used as a function
Was mach ich falsch? Aus der Tabelle sollen die Koordinaten für Drawrect gelesen werden, statt für jede Position einmal den Befehl Drawrect anzugeben.

LG Veritas
Tower: 2,5Ghz Quadcore/  8GB DDR2 Ram/ 1066Mhz FSB / ATI HD Radeon 4860.
Mobil:  DELL Studio XPS 16 / 2,53GHz intel Centrino 2 Duo / 4GB DDR 3 Ram/ 1066Mhz FSB/ ATI Radeon 4670 mobility

Never Argue with Idiots. They'll drag you down
to their level and beat you with experience.

Schranz0r

Code (glbasic) Select
DIM Position[10][2]

    Position[1][0] = 50
    Position[1][1] = 0
    Position[2][0] = 350
    Position[2][1] = 0
    Position[3][0] = 50
    Position[3][1] = 100
    Position[4][0] = 350
    Position[4][1] = 100
    Position[5][0] = 50
    Position[5][1] = 200
    Position[6][0] = 350
    Position[6][1] = 200
    Position[7][0] = 50
    Position[7][1] = 300
    Position[8][0] = 350
    Position[8][1] = 300
    Position[9][0] = 50
    Position[9][1] = 400
   
WHILE TRUE  
 
FOR x=1 TO 9    
DRAWRECT Position[x][0], Position[x][1], 200, 50,RGB(0xff, 0x00, 0x00)
NEXT

SHOWSCREEN
WEND
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Veritas

manchmal nimmt man den wald vor lauter Bäumen nicht! Danke!
Tower: 2,5Ghz Quadcore/  8GB DDR2 Ram/ 1066Mhz FSB / ATI HD Radeon 4860.
Mobil:  DELL Studio XPS 16 / 2,53GHz intel Centrino 2 Duo / 4GB DDR 3 Ram/ 1066Mhz FSB/ ATI Radeon 4670 mobility

Never Argue with Idiots. They'll drag you down
to their level and beat you with experience.

Kitty Hello

Keine Leerzeichen zwischen
  • [ und[y] ->
  • [y] =falsch
  • [y] = ok.

S.O.P.M.

Wäre es nicht vielleicht doch mal eine Überlegung wert, den Index immer bei 1 anfangen zu lassen? Es scheinen immer wieder Leute damit Probleme zu haben und auch mir bereitet es manchmal noch Mühe, mich da reinzudenken. Wenn ein Feld also mit beispielsweise 2 dimensioniert wird, dann sollte man den Index auch mit 1 und 2 ansprechen können. Gleiches für z.B. die MID$ Funktion: erstes Zeichen sollte den Index 1 haben. Intern kann GLBasic ja weiterhin mit 0 arbeiten aber der User muss das ja nicht mitbekommen ;)
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

NIEMALS!
Ein Feld bei 1 beginnen zu lassen halte ich für totalen Sc*~$%!
Das ist eine Enstellungssache, aber man gewöhnt sich wirklich schnell daran.

S.O.P.M.

Schon gut :) Im Nachhinein bin ich mir auch über einen großen Nachteil davon klar geworden: Alle bisherigen Codes müssten dann angepasst werden, was u. U. sehr aufwendig sein kann. Auf jedem Fall ist es gut, dass die Dimensionierung wenigstens logisch ist, also die angegebene Anzahl der Elemente auch der tatsächlichen entspricht - anders bei PB: ein DIM(8) hat dort 9 Elemente, 0 bis 8... das ist wirklich irgendwo dämlich!
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Tiuz

Ich machs fast in GLB fast immer so, dass ich ein Feld mit Dim[n+1]  größer als benötigt dimensioniere, und den nullten Index nicht verwende. Etwas "unproffesionell" aber für mich erleichterts die Indizierung enorm. :)
Tiuz.