Pseudo-Leucht-Dioden

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
Danilo
-= Anfänger =-
Beiträge: 2284
Registriert: 29.08.2004 03:07

Beitrag von Danilo »

Danilo hat geschrieben:

Code: Alles auswählen

Structure DISPLAY_FONT
  x.b[#FONT_W]
  y.b[#points_vert]
EndStructure
Das ist noch ein Überbleibsel im obigen Code der nicht mehr
gebraucht wird. Eigentlich wollte ich das ja anders machen.

Das ging leider nicht, da PB nicht einmal mehrdimensionale
Felder in Strukturen erlaubt.

Syntax Error:

Code: Alles auswählen

Structure DISPLAY_FONT
  font.b[8,8]
EndStructure
Garbage to the end of the line:

Code: Alles auswählen

Structure DISPLAY_FONT
  font.b[8][8]
EndStructure
Das wäre IMHO mal wieder etwas Grundlegendes was in
der Sprache fehlt, falls das hier jemand gebrauchen sollte.

Das vereinfacht einfach den Zugriff, und hier sollten auch
mehrdimensionale Felder möglich sein, so wie schon bei Dim.

Ein lauffähiges Beispiel wäre das:

Code: Alles auswählen

Structure FONT_XY
  x.b[8]
  y.b[8]
EndStructure

Structure DISPLAY_FONT
  font.FONT_XY
EndStructure

f.DISPLAY_FONT
For y = 0 To 7
  f\font\y[y] = 1
  For x = 0 To 7
    f\font\x[x] = 1
  Next x
Next y
Das finde ich aber irgendwie ziemlich häßlich und unleserlich -
muß man 'um die Ecke denken'.

[EDIT]
LOL... das geht ja garnicht. Das Beispiel erstellt zwei 8er-Felder,
also insgesamt 16 Felder, nicht 8x8 = 64 Felder.

Ich glaube so ist es momentan richtig:

Code: Alles auswählen

Structure FONT_XY
  x.b[8]
EndStructure

Structure DISPLAY_FONT
  font.FONT_XY[8]
EndStructure

f.DISPLAY_FONT
For y = 0 To 7
  For x = 0 To 7
    f\font[y]\x[x] = 1
  Next x
Next y
Boaaahh... :|
[/EDIT]


Einfacher PB-Style wäre eigentlich:

Code: Alles auswählen

Structure DISPLAY_FONT
  font.b[8,8]
EndStructure

f.DISPLAY_FONT
For y = 0 To 7
  For x = 0 To 7
    f\font[x,y] = 1
  Next x
Next y
cya,
...Danilo
"Ein Genie besteht zu 10% aus Inspiration und zu 90% aus Transpiration" - Max Planck
Benutzeravatar
Deeem2031
Beiträge: 1232
Registriert: 29.08.2004 00:16
Wohnort: Vorm Computer
Kontaktdaten:

Beitrag von Deeem2031 »

Man könnte es aber auch einfach so machen:

Code: Alles auswählen

Structure DISPLAY_FONT 
  font.b[8*8] 
EndStructure 

f.DISPLAY_FONT 
For y = 0 To 7 
  For x = 0 To 7 
    f\font[x+y*8] = 1 
  Next x 
Next y
Das finde ich immernoch besser als dein lauffähiger Code. Sollte aber trotzdem richtig funktionieren...
Bild
[url=irc://irc.freenode.org/##purebasic.de]irc://irc.freenode.org/##purebasic.de[/url]
Antworten