types in arrays..
Übersicht

![]() |
HackerBoyZBetreff: types in arrays.. |
![]() Antworten mit Zitat ![]() |
---|---|---|
hallo hab ein problem mit einem array-type (win_server).. weis absolut nicht was falsch ist... oder ist das falsch das in eine arrax zu packen?
Code: [AUSKLAPPEN] Function init() Global win_server:BOT_WINDOW[300] For i = 0 To 299 win_server:BOT_WINDOW[i] = New BOT_WINDOW Next EndFunction Function BOT_createwindow(iName$,iID%,ix,iy,iwidth%,iheight%,iactive% = 1,ilayer%=0) win_server:BOT_WINDOW[ID%].name$ = iname$ win_server:BOT_WINDOW[ID%].id% = iID% win_server:BOT_WINDOW[ID%].active% = iactive% win_server:BOT_WINDOW[ID%].layer% = ilayer% win_server:BOT_WINDOW[ID%].x% = ix% win_server:BOT_WINDOW[ID%].y% = iy% win_server:BOT_WINDOW[ID%].width% = iwidth% win_server:BOT_WINDOW[ID%].height% = iheight% EndFunction Type BOT_GUI Field x% Field y% Field width% Field height% EndType Type BOT_WINDOW Extends BOT_GUI Field Name$ Field ID% Field active% Field layer% Method draw(image:TImage) If active% = 1 Then 'fill SetScale((width - 5)/5,(height - 15)/5) DrawImage image,x% + 5,y% + 15,7 'top left SetScale(1,1) DrawImage image,x%,y%,0 DrawImage image,x%,y% + 5,6 DrawImage image,x%,y% + 10,12 'top middle SetScale((width - 5)/5,1) DrawImage image,x% + 5,y%,1 DrawImage image,x% + 5,y% + 5,7 DrawImage image,x% + 5,y% + 10,13 'top right SetScale(1,1) DrawImage image,x% + width% - 5,y%,2 DrawImage image,x% + width% - 5,y% + 5,8 DrawImage image,x% + width% - 5,y% + 10,14 'border left SetScale(1,(height-15)/5) DrawImage image,x%,y% + 15,6 'border right SetScale(1,(height-15)/5) DrawImage image,x% + width% - 5,y% + 15,8 'base left SetScale(1,1) DrawImage image,x%,y% + height% - 5,12 'base middle SetScale((width - 5)/5,1) DrawImage image,x% + 5,y% + height% - 5,13 'base right SetScale(1,1) DrawImage image,x% + width - 5,y% + height% - 5,14 'end EndIf EndMethod EndType '--- 'end '--- Graphics 800,600 init() bild = LoadAnimImage("bot_window.png",5,5,0,18) BOT_createwindow("hi",1,50,50,200,400) Repeat Cls win_server:BOT_WINDOW[1].draw(bild) Flip Until AppTerminate() |
||
![]() |
D2006Administrator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Der Zugrif auf das Array muss dann so aussehen:
Zitat: win_server[i] = New BOT_WINDOW
|
||
Intel Core i5 2500 | 16 GB DDR3 RAM dualchannel | ATI Radeon HD6870 (1024 MB RAM) | Windows 7 Home Premium
Intel Core 2 Duo 2.4 GHz | 2 GB DDR3 RAM dualchannel | Nvidia GeForce 9400M (256 MB shared RAM) | Mac OS X Snow Leopard Intel Pentium Dual-Core 2.4 GHz | 3 GB DDR2 RAM dualchannel | ATI Radeon HD3850 (1024 MB RAM) | Windows 7 Home Premium Chaos Interactive :: GoBang :: BB-Poker :: ChaosBreaker :: Hexagon :: ChaosRacer 2 |
![]() |
HackerBoyZBetreff: thx |
![]() Antworten mit Zitat ![]() |
---|---|---|
hmm ne klappt bei mir nicht ![]() ergebnis: Code: [AUSKLAPPEN] Function init() Global win_server:BOT_WINDOW[300] EndFunction Function BOT_createwindow(iName$,iID%,ix,iy,iwidth%,iheight%,iactive% = 1,ilayer%=0) win_server[iID%] = New BOT_WINDOW win_server:BOT_WINDOW[ID%].name$ = iname$ win_server:BOT_WINDOW[ID%].id% = iID% win_server:BOT_WINDOW[ID%].active% = iactive% win_server:BOT_WINDOW[ID%].layer% = ilayer% win_server:BOT_WINDOW[ID%].x% = ix% win_server:BOT_WINDOW[ID%].y% = iy% win_server:BOT_WINDOW[ID%].width% = iwidth% win_server:BOT_WINDOW[ID%].height% = iheight% EndFunction Type BOT_GUI Field x% Field y% Field width% Field height% EndType Type BOT_WINDOW Extends BOT_GUI Field Name$ Field ID% Field active% Field layer% Method draw(image:TImage) If active% = 1 Then 'fill SetScale((width - 5)/5,(height - 15)/5) DrawImage image,x% + 5,y% + 15,7 'top left SetScale(1,1) DrawImage image,x%,y%,0 DrawImage image,x%,y% + 5,6 DrawImage image,x%,y% + 10,12 'top middle SetScale((width - 5)/5,1) DrawImage image,x% + 5,y%,1 DrawImage image,x% + 5,y% + 5,7 DrawImage image,x% + 5,y% + 10,13 'top right SetScale(1,1) DrawImage image,x% + width% - 5,y%,2 DrawImage image,x% + width% - 5,y% + 5,8 DrawImage image,x% + width% - 5,y% + 10,14 'border left SetScale(1,(height-15)/5) DrawImage image,x%,y% + 15,6 'border right SetScale(1,(height-15)/5) DrawImage image,x% + width% - 5,y% + 15,8 'base left SetScale(1,1) DrawImage image,x%,y% + height% - 5,12 'base middle SetScale((width - 5)/5,1) DrawImage image,x% + 5,y% + height% - 5,13 'base right SetScale(1,1) DrawImage image,x% + width - 5,y% + height% - 5,14 'end EndIf EndMethod EndType '--- 'end '--- Graphics 800,600 init() bild = LoadAnimImage("bot_window.png",5,5,0,18) BOT_createwindow("hi",1,50,50,200,400) Repeat Cls win_server[1].draw(bild) Flip Until AppTerminate() |
||
![]() |
Geeecko |
![]() Antworten mit Zitat ![]() |
---|---|---|
win_server:BOT_WINDOW[ID%].name$ = iname$
----> win_server[ID%].name$ = iname$ klappt es so? |
||
![]() |
HackerBoyZ |
![]() Antworten mit Zitat ![]() |
---|---|---|
nein leider nicht...
fehlermeldung: Compile Error Expression of type "BOT_WINDOW" cannot be indexed |
||
![]() |
D2006Administrator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Diese Fehlermeldung passt zu dem Fehler, den du die ganze Zeit machst. Der Index [ID%] muss hinter den Variablen, nicht hinter den Variablentyp. | ||
Intel Core i5 2500 | 16 GB DDR3 RAM dualchannel | ATI Radeon HD6870 (1024 MB RAM) | Windows 7 Home Premium
Intel Core 2 Duo 2.4 GHz | 2 GB DDR3 RAM dualchannel | Nvidia GeForce 9400M (256 MB shared RAM) | Mac OS X Snow Leopard Intel Pentium Dual-Core 2.4 GHz | 3 GB DDR2 RAM dualchannel | ATI Radeon HD3850 (1024 MB RAM) | Windows 7 Home Premium Chaos Interactive :: GoBang :: BB-Poker :: ChaosBreaker :: Hexagon :: ChaosRacer 2 |
![]() |
HackerBoyZ |
![]() Antworten mit Zitat ![]() |
---|---|---|
geht auch ncht... ich habe das schonmal gehabt und weis das das [] hinter den typ der variable muss.
ohne den ganze array krahm gehts wunderbar ![]() Code: [AUSKLAPPEN] Type BOT_GUI Field x% Field y% Field width% Field height% EndType Type BOT_WINDOW Extends BOT_GUI Field Name$ Field ID% Field active% Field layer% Method draw(image:TImage) If active% = 1 Then 'fill SetScale((width - 5)/5,(height - 15)/5) DrawImage image,x% + 5,y% + 15,7 'top left SetScale(1,1) DrawImage image,x%,y%,0 DrawImage image,x%,y% + 5,6 DrawImage image,x%,y% + 10,12 'top middle SetScale((width - 5)/5,1) DrawImage image,x% + 5,y%,1 DrawImage image,x% + 5,y% + 5,7 DrawImage image,x% + 5,y% + 10,13 'top right SetScale(1,1) DrawImage image,x% + width% - 5,y%,2 DrawImage image,x% + width% - 5,y% + 5,8 DrawImage image,x% + width% - 5,y% + 10,14 'border left SetScale(1,(height-15)/5) DrawImage image,x%,y% + 15,6 'border right SetScale(1,(height-15)/5) DrawImage image,x% + width% - 5,y% + 15,8 'base left SetScale(1,1) DrawImage image,x%,y% + height% - 5,12 'base middle SetScale((width - 5)/5,1) DrawImage image,x% + 5,y% + height% - 5,13 'base right SetScale(1,1) DrawImage image,x% + width - 5,y% + height% - 5,14 'end EndIf EndMethod EndType '--- 'end '--- Graphics 800,600 bild = LoadAnimImage("bot_window.png",5,5,0,18) win:bot_window = New bot_window win.active = 1 Repeat Cls win.draw(bild) Flip Until AppTerminate() |
||
![]() |
D2006Administrator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Okay, wenn du das sagst. Lass dich nicht beirren, wenn ich das Gegenteil behaupte und die Fehlermeldung von BlitzMax ebenfalls das Gegenteil behauptet. Viel Erfolg noch ![]() |
||
Intel Core i5 2500 | 16 GB DDR3 RAM dualchannel | ATI Radeon HD6870 (1024 MB RAM) | Windows 7 Home Premium
Intel Core 2 Duo 2.4 GHz | 2 GB DDR3 RAM dualchannel | Nvidia GeForce 9400M (256 MB shared RAM) | Mac OS X Snow Leopard Intel Pentium Dual-Core 2.4 GHz | 3 GB DDR2 RAM dualchannel | ATI Radeon HD3850 (1024 MB RAM) | Windows 7 Home Premium Chaos Interactive :: GoBang :: BB-Poker :: ChaosBreaker :: Hexagon :: ChaosRacer 2 |
![]() |
d-bug |
![]() Antworten mit Zitat ![]() |
---|---|---|
1.
Code: [AUSKLAPPEN] Function init()
Global win_server:BOT_WINDOW[300] For i = 0 To 299 win_server:BOT_WINDOW[i] = New BOT_WINDOW Next EndFunction Das Array "win_server" ist nur innerhalb der Funktion global. Das kann so nicht gehen. Da können nur Funktionen, Schleifen, etc. drauf zugreifen die sich ebenfalls in der Function Init () befinden. Setze das Array außerhalb der Funktion und gut ists. 2. Code: [AUSKLAPPEN] Function BOT_createwindow(iName$,iID%,ix,iy,iwidth%,iheight%,iactive% = 1,ilayer%=0)
win_server[iID%] = New BOT_WINDOW win_server:BOT_WINDOW[ID%].name$ = iname$ win_server:BOT_WINDOW[ID%].id% = iID% win_server:BOT_WINDOW[ID%].active% = iactive% win_server:BOT_WINDOW[ID%].layer% = ilayer% win_server:BOT_WINDOW[ID%].x% = ix% win_server:BOT_WINDOW[ID%].y% = iy% win_server:BOT_WINDOW[ID%].width% = iwidth% win_server:BOT_WINDOW[ID%].height% = iheight% EndFunction Entscheide dich mal für iID oder ID. Die ganzen einträge der Daten werden mit ID 0 vonstatten gehen, weil du eben ID% nutzt und nicht iID%! Sowas passiert dir seltener, wenn du mal SuperStrict benutzen würdest. Dann hätte er direkt bemängelt, das es die Variable ID nicht gibt. Weiter hab ich mich da jetzt nicht durchgewuselt. |
||
![]() |
HackerBoyZ |
![]() Antworten mit Zitat ![]() |
---|---|---|
ok klappt thanks all | ||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group