Post by Kristal Rose Phoenix McKinstry on Oct 17, 2005 2:48:28 GMT -5
<?php
#d
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
#### chessobjects.rphj ###################################################################<br />
#### 2005.11.07 05:00 - km added array_reverse_ref & array_reverse_insides. ##############<br />');
#### 2005.11.05 04:45 - km now requires oTest.rpq . ###############
#### 2005.11.03 05:45 - km improved exhibit_array($laTable). ###############
#### 2005.11.02 23:30 - km modified mysql_fetch_table_array(&$lmResourceHandle) ##########
#### to return array (array count, table array). ##########
#### 2005.11.02 23:00 - km added echocall($lsToPrint) for debugging use. ###############
#### 2005.11.02 21:15 - km cleaned docs. ###############
#### 2005.11.02 05:00 - km REMOVED.RPQ FROM PROJECT. ###############
#### 2005.10.30 02:10 - km added function exhibit_array. ###############
#### 2005.10.29 02:30 - km added function mysql_fetch_table_array(&$lmResourceHandle) ####
#### 2005.10.26 22:40 - km modified to support new oServer object ! ! ###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.24 05:55 - km Added Forum Features. ###############
#### 2005.10.21 18:36 - km - include for testing snippets ###############
#### 2005.10.20 21:00 - km - NO EDITED Req'd for VAR NAMES new conventions ###############
#### 2005.10.20 01:23 - km added code documenation ###############
#### 2005.10.17.18:30 - km added oTest ###############
#### 2005.10.17.03:00 - km added oGame->fGetStatus() spec ###############
#### 2005.10.17.02:00 - km Title block ###############
##########################################################################################
##########################################################################################
#### Status: LOCKED - Perhaps finished - Request updates to data defs if needed. #########
##########################################################################################
##########################################################################################
#### Description: ####################################
#### Holds non sequential library includes/requires ####################################
#### Place for general object and data descriptions ####################################
##########################################################################################
##########################################################################################
#### Agenda: #############################################################################
#### #############################################################################
##########################################################################################
##########################################################################################
#### Programmers: Kristal McKinstry #################
##########################################################################################
##########################################################################################
require('oServer.rpq');
require('oBuildGui.rphj'); //Object for assembling the html
require('oCollectFormVars.rp'); // Object for handling requests for incoming form vars
require('oBoard.rpq'); // The game board Object
require('oStorage.rpq'); // Sql serialization utilities for storing and retrieving data.
require('oTest.rpq');
require('oForum.rpq');
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function mysql_fetch_table_array(&$lmResourceHandle){ // I can't believe php doesn't supply this.
// returns an array of row arrays.
// Usage list($liX, $laTable) = mysqlfetch... Test $liX>0 before using $laTable.
$X=0;
while ($laRow = mysql_fetch_row($lmResourceHandle)) {
$laTable[$X] = $laRow;
$X++;
}//end-while
if ($X==0) $laTable = NULL;
$laReturn = array($X, $laTable);
return($laReturn); ####@@@@ PROBLEM - WARNING IF EMPTY!
}//end-func mysql_fetch_table_array
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function exhibit_array($laTable){
####var_dump($laTable);#### foreach crashes if null values!
// displays array in table for testing.
if (is_null($laTable)) echocall('exhibit_array: Array was NULL!');
elseif (!is_array($laTable)) echocall('exhibit_array: Array wasnt an array!');
else {
echo '<table width="100%" border="3" cellspacing="2" cellpadding="2">';
reset($laTable); #### Fail here if table is empty!!
while ($array_pickapart = each ($laTable)) {
echo "<tr>";
foreach ($array_pickapart[1] as $blip) { // Uses value from each function for ForEach array source.
echo "<td>$blip</td>";// blips are values of sub-arrays.
} //end-foreach
echo "</tr>";
} //end-while
echo '</table>';
echo '<p><p><p>';
}//end-elseif
}//end-func exhibit_array
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function echocall($lsToPrint, $T=TRUE){
//if ($T) echo "<br /><font color='#330033' size='5'> $lsToPrint </font><br />";
if ($T) echo "<br /><font color='#ffffff' size='5'> $lsToPrint </font><br />";
}//end-func
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function &array_reverse_ref(&$a) { //Works. Reverses by ref.
$r = array();
for($i=0, $j=count($a); $i<count($a); $i++, $j--) {
$r[$i] =& $a[$j-1];
}
return $r;
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function array_reverse_insides($a) { // reverses rows and cols (but not z-axis+)
$r = array();
for($i=0, $j=count($a); $i<count($a); $i++, $j--) {
$r[$i] = $a[$j-1];
$r[$i] = array_reverse($r[$i]);
}
return $r;
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
?>
#d
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
#### chessobjects.rphj ###################################################################<br />
#### 2005.11.07 05:00 - km added array_reverse_ref & array_reverse_insides. ##############<br />');
#### 2005.11.05 04:45 - km now requires oTest.rpq . ###############
#### 2005.11.03 05:45 - km improved exhibit_array($laTable). ###############
#### 2005.11.02 23:30 - km modified mysql_fetch_table_array(&$lmResourceHandle) ##########
#### to return array (array count, table array). ##########
#### 2005.11.02 23:00 - km added echocall($lsToPrint) for debugging use. ###############
#### 2005.11.02 21:15 - km cleaned docs. ###############
#### 2005.11.02 05:00 - km REMOVED.RPQ FROM PROJECT. ###############
#### 2005.10.30 02:10 - km added function exhibit_array. ###############
#### 2005.10.29 02:30 - km added function mysql_fetch_table_array(&$lmResourceHandle) ####
#### 2005.10.26 22:40 - km modified to support new oServer object ! ! ###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.24 05:55 - km Added Forum Features. ###############
#### 2005.10.21 18:36 - km - include for testing snippets ###############
#### 2005.10.20 21:00 - km - NO EDITED Req'd for VAR NAMES new conventions ###############
#### 2005.10.20 01:23 - km added code documenation ###############
#### 2005.10.17.18:30 - km added oTest ###############
#### 2005.10.17.03:00 - km added oGame->fGetStatus() spec ###############
#### 2005.10.17.02:00 - km Title block ###############
##########################################################################################
##########################################################################################
#### Status: LOCKED - Perhaps finished - Request updates to data defs if needed. #########
##########################################################################################
##########################################################################################
#### Description: ####################################
#### Holds non sequential library includes/requires ####################################
#### Place for general object and data descriptions ####################################
##########################################################################################
##########################################################################################
#### Agenda: #############################################################################
#### #############################################################################
##########################################################################################
##########################################################################################
#### Programmers: Kristal McKinstry #################
##########################################################################################
##########################################################################################
require('oServer.rpq');
require('oBuildGui.rphj'); //Object for assembling the html
require('oCollectFormVars.rp'); // Object for handling requests for incoming form vars
require('oBoard.rpq'); // The game board Object
require('oStorage.rpq'); // Sql serialization utilities for storing and retrieving data.
require('oTest.rpq');
require('oForum.rpq');
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function mysql_fetch_table_array(&$lmResourceHandle){ // I can't believe php doesn't supply this.
// returns an array of row arrays.
// Usage list($liX, $laTable) = mysqlfetch... Test $liX>0 before using $laTable.
$X=0;
while ($laRow = mysql_fetch_row($lmResourceHandle)) {
$laTable[$X] = $laRow;
$X++;
}//end-while
if ($X==0) $laTable = NULL;
$laReturn = array($X, $laTable);
return($laReturn); ####@@@@ PROBLEM - WARNING IF EMPTY!
}//end-func mysql_fetch_table_array
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function exhibit_array($laTable){
####var_dump($laTable);#### foreach crashes if null values!
// displays array in table for testing.
if (is_null($laTable)) echocall('exhibit_array: Array was NULL!');
elseif (!is_array($laTable)) echocall('exhibit_array: Array wasnt an array!');
else {
echo '<table width="100%" border="3" cellspacing="2" cellpadding="2">';
reset($laTable); #### Fail here if table is empty!!
while ($array_pickapart = each ($laTable)) {
echo "<tr>";
foreach ($array_pickapart[1] as $blip) { // Uses value from each function for ForEach array source.
echo "<td>$blip</td>";// blips are values of sub-arrays.
} //end-foreach
echo "</tr>";
} //end-while
echo '</table>';
echo '<p><p><p>';
}//end-elseif
}//end-func exhibit_array
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function echocall($lsToPrint, $T=TRUE){
//if ($T) echo "<br /><font color='#330033' size='5'> $lsToPrint </font><br />";
if ($T) echo "<br /><font color='#ffffff' size='5'> $lsToPrint </font><br />";
}//end-func
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function &array_reverse_ref(&$a) { //Works. Reverses by ref.
$r = array();
for($i=0, $j=count($a); $i<count($a); $i++, $j--) {
$r[$i] =& $a[$j-1];
}
return $r;
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function array_reverse_insides($a) { // reverses rows and cols (but not z-axis+)
$r = array();
for($i=0, $j=count($a); $i<count($a); $i++, $j--) {
$r[$i] = $a[$j-1];
$r[$i] = array_reverse($r[$i]);
}
return $r;
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
?>