rickh57
10-08-2006, 03:54 PM
Hi:
I'm a software engineer with many years of experience using Java/C++. I'm trying to create a basketball scorekeeping application. My 1st task is to understand the PPL object model. I've created classes for team and player. The team class contains a linked list of players. My problem is that whenever I try traversing the list of players (to find the one with the correct number, compute the score, etc.), it never seems to step through all of the players. I'm not sure when to use references, newobject, etc. I guess that I'm spoiled by Java and PHP5, where everything is a reference! I'm sure that is something simple that I'm doing wrong or not doing... My test code is listed below.
I'm also having problems using the ListBox functions in the Simplified Windows API. Using either ListBox_Add or ListBox_Set seems to succeed (they return true), but the elements that I'm trying to add don't show up. I admit that it has been a very long time since I've done any low level Windows API programming, but am curious about the use of this function. I couldn't find any examples of list box usage in any of the demos.
Finally, just a comment. I've been using PHP and Perl a lot for the last few years and invariably when I create a variable, I put the $ at the beginning of the name not the end. I've been caught by this more times than I'd like to admit! However the error message that is displayed in this case is not very helpful: Invalid character '$' at character position 1586. :|
This is all with PPL 1.04 (Lite version). The Pro trial key that I used when I installed version 1.00 has already expired and until I get a good handle on whether or not I PPL will handle my needs, I'm not yet ready to purchase the Pro or Standard versions.
#class player
Private(number$, score$, fowls$);
nproc create
number$ = args$[0];
score$ = 0;
fowls$ = 0;
end;
public proc addScore(points$)
score$ += points$;
end;
public func getScore
return(score$);
end;
public func getNumber
return(number$);
end;
public func toString
return("Number=" + number$ + ",score=" + score$ + ",fowls=" + fowls$);
end;
#endclass
#class team
Private(players$, numPlayer$);
nproc create
List(players$);
numPlayer$ = 0;
end;
proc destroy
ForEach(players$)
NewObject(p$, "player", players$);
FreeObject(p$);
end;
free(players$);
end;
public proc addPlayer(player$)
NewObject(p$, "player", &player$);
ShowMessage("Player:" + p.toString);
Add(players$, &p$);
end;
public func getScore
ShowMessage("getScore(): Entry");
score$ = 0;
ForEach(players$,&obj$)
NewObject(p$, "player", &obj$);
score$ = p.getScore;
end;
ShowMessage("getScore(): Exit, score=" + score$);
return(score$);
end;
public func getPlayer(number$)
ShowMessage("getPlayer(): Entry, number is " + number$);
retVal$ = 0;
ForEach(players$,&obj$)
NewObject(p$, "player", &obj$);
ShowMessage("player is " + p.toString);
if (p.getNumber == number$)
retVal$ = &p$;
break;
end;
end;
return (retVal$);
end;
#endclass
proc init
Global(homeTeam$);
#object team homeTeam$;
for(i$,0,5)
#object player aPlayer$(i$);
aPlayer.addScore(i$);
homeTeam.addPlayer(&aPlayer$);
end;
// this should add 15 points to player 1's points...
&obj$ = homeTeam.getPlayer(1);
NewObject(p$, "player", &obj$);
p.addScore(15);
end;
I'm a software engineer with many years of experience using Java/C++. I'm trying to create a basketball scorekeeping application. My 1st task is to understand the PPL object model. I've created classes for team and player. The team class contains a linked list of players. My problem is that whenever I try traversing the list of players (to find the one with the correct number, compute the score, etc.), it never seems to step through all of the players. I'm not sure when to use references, newobject, etc. I guess that I'm spoiled by Java and PHP5, where everything is a reference! I'm sure that is something simple that I'm doing wrong or not doing... My test code is listed below.
I'm also having problems using the ListBox functions in the Simplified Windows API. Using either ListBox_Add or ListBox_Set seems to succeed (they return true), but the elements that I'm trying to add don't show up. I admit that it has been a very long time since I've done any low level Windows API programming, but am curious about the use of this function. I couldn't find any examples of list box usage in any of the demos.
Finally, just a comment. I've been using PHP and Perl a lot for the last few years and invariably when I create a variable, I put the $ at the beginning of the name not the end. I've been caught by this more times than I'd like to admit! However the error message that is displayed in this case is not very helpful: Invalid character '$' at character position 1586. :|
This is all with PPL 1.04 (Lite version). The Pro trial key that I used when I installed version 1.00 has already expired and until I get a good handle on whether or not I PPL will handle my needs, I'm not yet ready to purchase the Pro or Standard versions.
#class player
Private(number$, score$, fowls$);
nproc create
number$ = args$[0];
score$ = 0;
fowls$ = 0;
end;
public proc addScore(points$)
score$ += points$;
end;
public func getScore
return(score$);
end;
public func getNumber
return(number$);
end;
public func toString
return("Number=" + number$ + ",score=" + score$ + ",fowls=" + fowls$);
end;
#endclass
#class team
Private(players$, numPlayer$);
nproc create
List(players$);
numPlayer$ = 0;
end;
proc destroy
ForEach(players$)
NewObject(p$, "player", players$);
FreeObject(p$);
end;
free(players$);
end;
public proc addPlayer(player$)
NewObject(p$, "player", &player$);
ShowMessage("Player:" + p.toString);
Add(players$, &p$);
end;
public func getScore
ShowMessage("getScore(): Entry");
score$ = 0;
ForEach(players$,&obj$)
NewObject(p$, "player", &obj$);
score$ = p.getScore;
end;
ShowMessage("getScore(): Exit, score=" + score$);
return(score$);
end;
public func getPlayer(number$)
ShowMessage("getPlayer(): Entry, number is " + number$);
retVal$ = 0;
ForEach(players$,&obj$)
NewObject(p$, "player", &obj$);
ShowMessage("player is " + p.toString);
if (p.getNumber == number$)
retVal$ = &p$;
break;
end;
end;
return (retVal$);
end;
#endclass
proc init
Global(homeTeam$);
#object team homeTeam$;
for(i$,0,5)
#object player aPlayer$(i$);
aPlayer.addScore(i$);
homeTeam.addPlayer(&aPlayer$);
end;
// this should add 15 points to player 1's points...
&obj$ = homeTeam.getPlayer(1);
NewObject(p$, "player", &obj$);
p.addScore(15);
end;