Seite 1 von 1

[Gelöst] Liste will nicht funktionieren

Verfasst: 06.04.2008 20:39
von Tombi
Was am Ende ausgegeben werden soll ist selbsterklärend.
Sollte eigendlich alles funktionieren :(

Code: Alles auswählen

;- OpenFile
OpenFile(0,"map.txt")

;
Structure Maps
Name.s
Hoehe.w
Breite.w
PlayerX.w
PlayerY.w
EndStructure

Structure Fields
X.w
Y.w
House.w
Boden.w
State.w
Target.w
EndStructure

NewList Maps.Maps() 
NewList Fields.Fields() 



Procedure XML_Game(A$)

X = FindString(A$,"<game>",1)

If X
  ProcedureReturn 1
Else
  ProcedureReturn 0
EndIf

EndProcedure







Procedure XML_Map(A$)

X = FindString(A$,"<map",1)

If X

  Y = FindString(A$,"name=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Map_Name$ = Mid(A$, Start+1, Ende-Start-1)
    
  Y = FindString(A$,"height=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Map_Hoehe.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"width=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Map_Breite.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"playerx=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Map_PlayerX.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"playery=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Map_PlayerY.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
AddElement(Maps())
Maps()\Name = Map_Name$
Maps()\Hoehe = Map_Hoehe
Maps()\Breite = Map_Breite
Maps()\PlayerX = Map_PlayerX
Maps()\PlayerY = Map_PlayerY
    
Else
  ProcedureReturn 0
EndIf

EndProcedure







Procedure XML_Field(A$)

X = FindString(A$,"<field",1)

If X

  Y = FindString(A$,"x=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Field_X.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"y=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Field_Y.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"house=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Field_House.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"state=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Field_State.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"boden=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Field_Boden.b = Val(Mid(A$, Start+1, Ende-Start-1))
    
  Y = FindString(A$,"target=",X)
    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1) 
    Field_Target.b = Val(Mid(A$, Start+1, Ende-Start-1))

AddElement(Fields())
Fields()\X = Field_X.b
Fields()\Y = Field_Y
Fields()\House = Field_House
Fields()\Boden = Field_Boden
Fields()\State = Field_State
Fields()\Target = Field_Target




Else
  ProcedureReturn 0
EndIf

EndProcedure







Repeat
String$ = ReadString()
XML_Map(String$)
XML_Field(String$)

Until Eof(0)

While NextElement(Maps())
MessageRequester("Go","X: "+Str(Fields()\X),0)
Wend

While NextElement(Fields())
MessageRequester("Go","X: "+Str(Fields()\X),0)
Wend

Verfasst: 06.04.2008 20:52
von STARGÅTE
du hast ResetList() vergessen

Code: Alles auswählen

ResetList(Maps()) 
While NextElement(Maps()) 
MessageRequester("Go","X: "+Str(Fields()\X),0) 
Wend 

ResetList(Fields()) 
While NextElement(Fields()) 
MessageRequester("Go","X: "+Str(Fields()\X),0) 
Wend

Verfasst: 07.04.2008 13:33
von Tombi
Vielen Dank :)

Verfasst: 07.04.2008 17:50
von Tombi

Code: Alles auswählen

    Start = FindString(A$,Chr(34), Y+4)
    Ende =  FindString(A$,Chr(34), Start+1)
    Field_X.b = Val(Mid(A$, Start+1, Ende-Start-1))
    Debug Field_X
Ergebnis ist immer "-89". Wenn ich den Variablentyp höher stelle kommt genauso eine höhere jedoch immer gleiche Zahl raus. :(

- Tombi-

Verfasst: 07.04.2008 18:10
von Kiffi
Tombi hat geschrieben:Ergebnis ist immer "-89".
welchen Inhalt hat denn A$? (-> Debug A$)
Tombi hat geschrieben:Wenn ich den Variablentyp höher stelle kommt genauso eine höhere jedoch immer gleiche Zahl raus. :(
was meinst Du mit 'Variablentyp'?

Grüße ... Kiffi

P.S.: Korrigiere bitte mal Deine Signatur!

Verfasst: 07.04.2008 18:51
von Tombi

Code: Alles auswählen

<field x="10" y="19" target="house_1,5,8" />
Das gibt Debug A$ aus ;)

Verfasst: 07.04.2008 19:00
von STARGÅTE
hmm vllt ließt du ja die falschen bereiche:
also nicht 10 oder 19 sondern y=

lass dir mal bitte Mid(A$, Start+1, Ende-Start-1) debuggen

Verfasst: 07.04.2008 19:54
von Tombi
Da haben wir es.

Schon beim ersten wird Y+4 genommen, da kommt Y+1 hin.