Example #1
0
function stb_loaddata($stbindex, &$x, &$y, &$f, $arrayfile)
{
    $i = 0;
    // try to get sorted array it from file
    if (arrayfile($arrayfile, $array, "GET") === FALSE) {
        // actually load
        if (!($fp = fopen($file, "r"))) {
            echo "cannot open {$file}!\n";
            return FALSE;
        }
        while ($line = fgets($fp, 128)) {
            //list ($x[$i],$y[$i],$f[$i])=split(" ",$line,3);
            list($array[$i]['x'], $array[$i]['y'], $array[$i]['f']) = split(" ", trim($line), 3);
            $i++;
            // echo "$i =" . $x[$i-1][0] . "$line";
        }
        fclose($fp);
        $B = new mdasort();
        $B->aData = $array;
        $B->aSortKeys = array(array('x', 'ASC'), array('y', 'DESC'));
        $B->sort();
        echo "get it from {$file}\n";
        if (arrayfile($arrayfile, $array, "DUMP") === FALSE) {
            echo "{$arrayfile} write failed\n";
        }
    }
    for ($j = 0; $j < count($array); $j++) {
        $x[$j] = $array[$j]['x'];
        $y[$j] = $array[$j]['y'];
        $f[$j] = $array[$j]['f'];
    }
    return TRUE;
}
Example #2
0
 function load($file)
 {
     arrayfile($file, $this->desc, "GET");
     return $this->desc;
 }