I can't seem to get the php program to write the results to the fshp and fbo files under the function write files section at the bottom of the code to complete writing to the files. I am not allowed to use global.

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter6: Sub And Function Procedures
Section: Chapter Questions
Problem 1MQ3
icon
Related questions
Question

I can't seem to get the php program to write the results to the fshp and fbo files under the function write files section at the bottom of the code to complete writing to the files. I am not allowed to use global.

<?php
// MAINLINE
//input vars
$orderId = "";
$itemId = "";
$qtyRequested = 0;
$qtyOnHand = 0;
  
// output vars
$qtyShipped = 0;
$qtyBackOrdered = 0;
$message = "";
  
  
PrepareFiles($fshp,$fbo );
  
printf("\n Enter the Order Id or (0) to exit program: ");
fscanf(STDIN, "%s", $orderId);
while($orderId != "0")
{
printf("\n Enter the Item Id or (0) to exit the order: " );
fscanf(STDIN, "%s", $itemId);
while($itemId != "0")
{
printf("\n Enter the Qty Requested:");
fscanf(STDIN, "%d", $qtyRequested);
printf("\n Enter the Qty On Hand:");
fscanf(STDIN, "%d", $qtyOnHand);
printf("\n Enter the Item Id or (0) to exit the order: " );
fscanf(STDIN, "%s", $itemId);
}
printf("\n Enter the Order Id or (0) to exit program: ");
fscanf(STDIN, "%s", $orderId);
}
  
fclose($fshp);
fclose($fbo);

// END MAINLINE
  
function PrepareFiles(&$fshp,&$fbo )
{
$fshp = fopen("shipped.txt", "w") or die("shipped not opened");
fprintf($fshp,"\n SHIPPED REPORT\n");
fprintf($fshp,"\n Order Id Item Id Shipped Message\n");
  
$fbo = fopen("backorder.txt", "w") or die("backorder not opened");
fprintf($fbo,"\n BACK ORDER REPORT\n");
fprintf($fbo,"\n Order Id Item Id Backordered\n");
  
}
function DoCalcs($qtyOnHand,$qtyRequested, &$qtyShipped, &$qtyBackOrdered, &$message)
{
printf("\n DoCalcs\n"); ///
if($qtyRequested <= $qtyOnHand)
{
$qtyShipped = $qtyRequested;
$qtyBackordered = 0;
$message = "Fully Filled";
}
else
{
if($qtyOnHand !=0)
{
$qtyShipped = $qtyOnHand;
$qtyBackOrdered = $qtyRequested - $qtyOnHand;
$message = "Partially Filled";
}
else
{
$qtyShipped = 0;
$qtyBackOrdered = $qtyRequested;
$message = "Out of Stock";
}
}
}

function WriteFiles($fship, $fbo, $orderId, $itemId, $qtyOnHand, $qtyRequested, &$qtyShipped, &$qtyBackOrdered, &$message)
{

printf("\n WriteFiles\n");
fprintf($fshp, "$orderId $itemId $qtyShipped $message\n");
fprintf($fbo, "$orderId $itemId $qtyBackOrdered\n");

}

?>

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,