(Just learning a bit of scripting again
There's a piece of code in your script:
Code: Select all
IF ($newsize == "- " || $newsize == "0") {
$evalpercent="0.0";
}
ELSEIF ($evalpercent == "0.00") {
$evalpercent="< 0.01";
}
ELSE{
$newpercent= gettoken ($percent,$token,"<crlf>");
$evalpercent= eval ($newpercent);
$dotpos= strpos($evalpercent,".",0);
$integer= substr ($evalpercent,0,$dotpos);
$decimal=substr ($evalpercent,$dotpos,3);
$evalpercent="$integer$decimal";
}
Should be about:
Code: Select all
IF ($newsize == "- " || $newsize == "0") {
$evalpercent="0.0";
}
ELSE{
$newpercent= gettoken ($percent,$token,"<crlf>");
$evalpercent= eval ($newpercent);
$evalpercent = substr($evalpercent, 0, strpos($evalpercent, ".")+3); // trunc to 2 decimals
/* *** next 4 lines commented: replaced by previous line
$dotpos= strpos($evalpercent,".",0);
$integer= substr ($evalpercent,0,$dotpos);
$decimal=substr ($evalpercent,$dotpos,3);
$evalpercent="$integer$decimal"; *** */
IF ($evalpercent == "0.00") {
$evalpercent="< 0.01"; }
}
By trying to understand the code I noticed a part that could be much shorter - with the same function. Here a piece of code with your old part commented by /* */, and a replacement in front of it. You could use the replacement, if you like:
Code: Select all
$totalKB = substr($totalKB, 0, strpos($totalKB, ".")+3); // trunc to 2 decimals
$totalMB = substr($totalMB, 0, strpos($totalMB, ".")+3);
$totalGB = substr($totalGB, 0, strpos($totalGB, ".")+3);
/* **** //123.4567
$getKB= gettoken ("$totalKB",1,"."); //123
$dotpos= strpos($totalKB,".",0); //3
$integer= substr ($totalKB,0,$dotpos); //123
$decimal=substr ($totalKB,$dotpos,3); //.45
$totalKB="$integer$decimal"; //123.45
$getMB= gettoken ("$totalMB",1,".");
$dotpos= strpos($totalMB,".",0);
$integer= substr ($totalMB,0,$dotpos);
$decimal=substr ($totalMB,$dotpos,3);
$totalMB="$integer$decimal";
$getGB= gettoken ("$totalGB",1,".");
$dotpos= strpos($totalGB,".",0);
$integer= substr ($totalGB,0,$dotpos);
$decimal=substr ($totalGB,$dotpos,3);
$totalGB="$integer$decimal";
*** */
XYplorer Beta Club