| Author |  | 
      
        | MAWilsonPE Newbie
 
  
  
 Joined: May 30 2008
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          This should be easy but I am having trouble.  I am trying to create a loop in a macro that executes a set number of times(3).
           | Posted: May 20 2010 at 10:29 | IP Logged |   |  
           | 
 |  
 Set System   TEMP3   1
 Set  System   TEMP1   ph_regexdiff( "title=","AAAA","[TEMP1]",1,1)+"AAAA"
 Set  System   TEMP2   left(ph_regex diff("title=","AAAA","[TEMP1]",1,1),1)
 Set  Global    SITE77   "{SITE 77}"+"[TEMP2]"
 Set System   TEMP3   [TEMP3]+1
 Jump                         if  ([TEMP3]=3,999,-4)
 
 I get the error:  Syntax Error in Formula: if(2=3,999,-4)
 
 Shouldn't 2=3 be FALSE and return a value of -4 for the Jump function?
 
 Edited by MAWilsonPE - May 20 2010 at 10:35
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | sjvonstein Groupie
 
  
 
 Joined: February 05 2010
 Location: United States
 Online Status: Offline
 Posts: 75
 | 
          Here's how I do a repeat in one of my macros.  If you'd like an export format, let me know
           | Posted: May 20 2010 at 10:54 | IP Logged |   |  
           | 
 |  
 FORMULA ph_setglobal_a("COUNTDOWN",30)
 
 LABEL INCREMENT
 WAIT 1
 FORMULA ph_addtoglobal("COUNTDOWN", - 1)
 Goto Label if({COUNTDOWN}=0,"END","INCREMENT")
 
 LABEL END
 MACRO ALLOFF
 FORMULA ph_setglobal_a("COUNTDOWN"," ")
 MACRO TV OFF
 
 Edited by sjvonstein - May 20 2010 at 10:55
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | MAWilsonPE Newbie
 
  
  
 Joined: May 30 2008
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          OK, I see.  I can make that work.
           | Posted: May 20 2010 at 10:58 | IP Logged |   |  
           | 
 |  
 I would still like to know why my "if" statement is wrong....
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | sjvonstein Groupie
 
  
 
 Joined: February 05 2010
 Location: United States
 Online Status: Offline
 Posts: 75
 | 
          It's possible the negative value is the problem.  I've heard placing a space between the negative sign and value may be a fix.  Try substituting the negative for a positive as a quick check.
           | Posted: May 20 2010 at 11:02 | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | BeachBum Super User
 
  
  
 Joined: April 11 2007
 Location: United States
 Online Status: Offline
 Posts: 1880
 | 
          I don’t have PH in front of me now but I would remove the comma from 3999.
           | Posted: May 20 2010 at 11:23 | IP Logged |   |  
           | 
 |  
 __________________
 Pete - X10 Oldie
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | sjvonstein Groupie
 
  
 
 Joined: February 05 2010
 Location: United States
 Online Status: Offline
 Posts: 75
 | 
          He's not intending the number 3 thousand nine hundred ninety nine.  He's trying to return an if 3, then 999, else -4
           | Posted: May 20 2010 at 11:24 | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | MAWilsonPE Newbie
 
  
  
 Joined: May 30 2008
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          Hmmm,
           | Posted: May 20 2010 at 11:24 | IP Logged |   |  
           | 
 |  
 I tried your suggestion and it is not incrementing.  In the event log I can see that the global variable COUNTDOWN is changed from "blank" to 14, then 14 to "blank" again.  It seems the FORMULA ph_addtoglobal("COUNTDOWN", - 1) is not working.
 I tried changing the - 1 to -1 and even to 1 and it nevers adds it to COUNTDOWN.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | sjvonstein Groupie
 
  
 
 Joined: February 05 2010
 Location: United States
 Online Status: Offline
 Posts: 75
 | 
          set all macro/formula executions to POST instead of immediate and try again.
           | Posted: May 20 2010 at 11:28 | IP Logged |   |  
           | 
 |  
 Retain the space in - 1
 
 Edited by sjvonstein - May 20 2010 at 11:29
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | MAWilsonPE Newbie
 
  
  
 Joined: May 30 2008
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          OK,
           | Posted: May 20 2010 at 11:37 | IP Logged |   |  
           | 
 |  
 Using a combination of mine and yours I got it to work.  It seems the JUMP function will not accept a negative value and that is my syntax error.  So I am using two LABELS and the Goto Label to get the loop working. I am using the counter I set up, TEMP3 increments and the Goto Label jumps ot of the loop when TEMP3 hits the limit.
 
 Thanks alot!
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | BeachBum Super User
 
  
  
 Joined: April 11 2007
 Location: United States
 Online Status: Offline
 Posts: 1880
 | 
          Damn, I better find new glasses…
           | Posted: May 20 2010 at 11:38 | IP Logged |   |  
           | 
 |  
 __________________
 Pete - X10 Oldie
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | sjvonstein Groupie
 
  
 
 Joined: February 05 2010
 Location: United States
 Online Status: Offline
 Posts: 75
 | 
          You're welcome.
           | Posted: May 20 2010 at 11:43 | IP Logged |   |  
           | 
 |  
 lol@ BeachBum
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | MAWilsonPE Newbie
 
  
  
 Joined: May 30 2008
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          Maybe it is the IF statement that does not like to return a negative value than the JUMP.  Goto Label works.
           | Posted: May 20 2010 at 11:48 | IP Logged |   |  
           | 
 |  
 What happens if the formula is set to Post instead of Immediate?
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | sjvonstein Groupie
 
  
 
 Joined: February 05 2010
 Location: United States
 Online Status: Offline
 Posts: 75
 | 
          It's possible that the jump command isn't accepting a negative.  Jump seems relatively obsolete with GoTo commands being so easy to use and are not dependent on changing line numbers.  I'm not clear on the difference between post/immediate.  I only know that changing most of my macros functions to "POST" has solved many problems.
           | Posted: May 20 2010 at 12:05 | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | BeachBum Super User
 
  
  
 Joined: April 11 2007
 Location: United States
 Online Status: Offline
 Posts: 1880
 | 
          OK, now that I have my glasses on try this for giggles.
           | Posted: May 20 2010 at 16:21 | IP Logged |   |  
           | 
 |  If  (ph_getvar_n(2,4) = 3, 999, -4)
 Put a space before the dash.
 
 
 __________________
 Pete - X10 Oldie
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | MAWilsonPE Newbie
 
  
  
 Joined: May 30 2008
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          OK, it seems that the following:
           | Posted: May 20 2010 at 18:11 | IP Logged |   |  
           | 
 |  If(ph_getvar_n(2,4)=3,999, -4)
 is the same as If([TEMP4]=3,999, -4)
 
 I am using TEMP3 so that should be:
 If(ph_getvar_n(2,3)=3,999, -4)
 
 Not sure if this has an advantage over If([TEMP3]=3,999, -4)
 
 I like the Goto Label, it works.  It may be that PH does not like JUMP = -4
 
 Thanks for all your help, I got it working w/ Goto Label
 
 Edited by MAWilsonPE - May 20 2010 at 18:13
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | BeachBum Super User
 
  
  
 Joined: April 11 2007
 Location: United States
 Online Status: Offline
 Posts: 1880
 | 
          Yep for some reason PH_GETVAR will always work and [xxxx]  sometimes.  I use GOTO and JUMP. Prefer GOTO in larger macros. Minus (-4) is working for me.
           | Posted: May 20 2010 at 18:54 | IP Logged |   |  
           | 
 |  
 __________________
 Pete - X10 Oldie
 | 
       
        | Back to Top |     | 
       
       
        |  |