Assume the following variable values were set earlier in the code:
LSLATHOR = 1780
, NRSLATVER = 34
Then I have these two lines of GWBASIC:
100 PITCHHOR=(LSLATHOR/(NRSLATVER+1)) : LSLATHOR=PITCHHOR*(NRSLATVER+1)
110 IF PITCHHOR>72 THEN NRSLATVER=NRSLATVER+1:GOTO 100
120 LPRINT "HORIZONTAL PITCH is equal to : ";PITCHHOR;
Now if I wanted to put this logic as a PHP function how would I go about it?:
function calc_h($slat_length_h, $slat_qty_v) {
$pitch_h = ($slat_length_h / ($v_slat_qty + 1));
if ($pitch_h > 72) {
while ($pitch_h > 72) {
$v_slat_qty += 1;
$slat_length_h = $pitch_h * ($v_slat_qty + 1);
$pitch_h = ($slat_length_h / ($v_slat_qty + 1));
}
}
return $pitch_h;
}
$slat_length_h = 1780;
$slat_qty_v = 34;
echo calc_h($slat_length_h, $slat_qty_v);
What you need to know is that a condition will sometimes exist where PITCHHOR > 72
then it needs to adjust/re-calculate the $pitch_h according to the GWBasic script.
I hope I provided enough info. Ty vm.
I'd write as follows. But since you have the original code, you can simply try to plug in a few sample values and compare the results.
function calc_pitchhor($lslathor, $nrslatver) {
do {
$pitchhor = ($lslathor/($nrslatver+1));
$lslathor = $pitchhor*($nrslatver+1);
++$nrslatver;
} while($pitchhor > 72)
return $pitchhor;
}
$lslathor = 1780;
$nrslatver = 34;
echo "HORIZONTAL PITCH is equal to: ", calc_pitchhor($slat_length_h, $slat_qty_v);