Jump to content

getField() in infinite loop


This topic is 3081 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hello,

I want to have a script pause when a field is not empty, and to continue as it is not empty any more.

So I tried this infinite loop:

while (1 == 1)
{
   echo "Test if field is empty..." . "<br>";
   $val_block = $record->getField("web_block_n");
   if ($val_block == "") {break;}
   echo "wait for field is not empty..." . "<br>";
   sleep(5);            
}

Result: When field "web_block_n" has already been empty, the loop breaks immediately as expected.

But if the field is not empty before the php script starts, and I make it empty after start, nothing happens.

The browser from where the script was called, is just in wait mode, and no echo output at all is shown.

What is wrong?

 

Thank You

Wolfgang

 

Link to comment
Share on other sites

Well, it would - where is the web submit to actually make the field in the database change?

The web is not like FM - you need to actively make a change, and then that value will persist in the web browser until another call is made...

Link to comment
Share on other sites

  • Newbies

I change (and save) the field by hand, directly, in the FM layout, while the script is running.

The complete code is like this:

    $theCommand = $fm->newCompoundFindCommand($layoutName);
    $request = $fm->newFindRequest($layoutName);
    $request->addFindCriterion('web_identifier_x', "identifier_a");
    $theCommand->add(1, $request);
    $resultfm = $theCommand->execute();
    $records = $resultfm->getRecords();
    foreach ($records as $record)
    {
      ...
      while(1)
      {
            $val_block = $record->getField("web_block_n");
            if ($val_block == "") {break;}
            sleep(3);
      }
      ...
    }

I there something I miss? Do I have to repeat i.e. getrecords(), or execute() as well inside of the loop ?

Wolfgang

Link to comment
Share on other sites

This topic is 3081 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.