Found an issue in SpiderBasic ? Please report it here !
ricardo_sdl
 
Posts: 12
Joined: Fri Jan 10, 2020 12:30 pm

Couldn't print the whole list

by ricardo_sdl Thu Feb 20, 2020 8:47 pm

The following code works on PureBasic but not on SpiderBasic:
Code: Select all
Structure TScore : Score.u : Run.u : TotalScore.l : Active.a : EndStructure

Global NewList Scores.TScore()

Procedure GetScores(List ReturnedScores.TScore())
  ClearList(ReturnedScores()) : CopyList(Scores(), ReturnedScores())
EndProcedure
Procedure SortScores(List Scores.TScore())
  Define i.w, j.w, ScoresSize.w = ListSize(Scores())
  For i = 0 To ScoresSize - 2
    For j = 0 To ScoresSize - i  - 2 : *First.TScore = SelectElement(Scores(), j) : *Second.TScore = SelectElement(Scores(), j + 1)
      If *First\TotalScore < *Second\TotalScore
        SwapElements(Scores(), *First, *Second)
      EndIf
    Next j
  Next i
EndProcedure

Procedure DrawScores()
  NewList TheScores.TScore() : GetScores(TheScores())
  If ListSize(TheScores()) > 0
    LastElement(TheScores()) : NewestScore.TScore = TheScores() : DeleteElement(TheScores(), #True)
    SortScores(TheScores())
    ResetList(TheScores()) : AddElement(TheScores()) : TheScores() = NewestScore : i.u = 0
    ForEach TheScores()
      Debug TheScores()\TotalScore
    Next
  EndIf
EndProcedure

Procedure CallDrawScores()
  DrawScores()
EndProcedure



AddElement(Scores()) : Scores()\TotalScore = 8
AddElement(Scores()) : Scores()\TotalScore = 9
AddElement(Scores()) : Scores()\TotalScore = 2

ForEach Scores()
  Debug Scores()\TotalScore
Next

Debug "----------"
DrawScores()


At the end of DrawScores() procedure, the ForEach loop is not printing all the values inside TheScores() list. Is there something I'm missing here?
Thanks!
Fred
Site Admin
 
Posts: 1298
Joined: Mon Feb 24, 2014 10:51 am

Re: Couldn't print the whole list

by Fred Tue May 19, 2020 8:07 am

Moved for investigation
Return to Bugs Reports

Who is online

Users browsing this forum: No registered users and 3 guests