OK, thanks to the help of kind people here I've got a working simple
example program(see below).

=The Example Code=
-test.php includes next lines
<?php
class Test extends AppModel
{
 var $name = 'Test';
 var $useTable = false;

 function myfunction($i) {
   switch($i)
   {
     case 1:
       $result[0] = 'lemon';
       $result[1] = 'banana';
       $result[2] = 'apple';
       break;
     case 2:
       $result[0] = 'lion';
       $result[1] = 'tiger';
       $result[2] = 'monkey';
       break;
     case 3:
       $result[0] = 'red';
       $result[1] = 'blue';
       $result[2] = 'green';
       break;
   }
   return $result;
 }
}

-tests_controller.php includes next lines.

<?php
class TestsController extends AppController {
 var $name = 'Tests';

 function pass() {
   $result = array();
   for ($i = 1; $i <= 3; $i++) {
      $result = am($result, $this->Test->myfunction($i));
   }
   $this->set('result',$result);
 }
}
?>

-And, pass.thtml includes next lines.

<?php
$count = count($result);
for ($i=0; $i < $count; $i++) {
 echo $result[$i] . "<br />";
}
?>

Currently, he output is:

lemon
banana
apple
lion
tiger
monkey
red
blue
green

But can I have an output like this?:

Now, fruits are being collected!
lemon
banana
apple
Now, animals are being collected!
lion
tiger
monkey
Now colors are being collected!
red
blue
green

I want to show progress indicator to the user of my program for each
run of $i for loop of pass(). The pass() function could be modified
like the following(see below), but it does not give the expected
results since $message and $result are overwritten repeatedly. This
time I don't want to merge array of fruits, animals, and colors as I
did previously. I want to make Controller output each array into View.
this kind of job was easy when design and logic were not seperated, but
now that logic(Controller) and design(View) are seperated, and it doen
not seem to be so easy at least to me.
Could anyone show me how to modify the Controller and View?

 function pass() {
   $result = array();
   for ($i = 1; $i <= 3; $i++) {
        if ($i == 1) $this->set('message',"Now, fruits are being
collected.<br>");
        if ($i == 2) $this->set('message',"Now, animals are being
collected.<br>");
        if ($i == 3) $this->set('message',"Now, colors are being
collected.<br>");
$this->set('result', $this->Test->myfunction($i)); }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to