Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: I’m Going Crazy! Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: January 18 2009 at 20:17 | IP Logged Quote GadgetGuy

OK. Time to go to the well again.

After 5 hours of fighting a “bug” that makes no sense, I’m tapped out and not making any progress and need another pair of eyes.

The following appears to be fully correct to me but doesn’t work. All I am trying to do is set a Global Variable to a “1” or a “0”. In the following example I’m just simply trying to make it “0”.

The 3rd line ph_setglobal_a(“[LOCAL2]”,0) does not work even though LOCAL2 appears to be correctly set to “FLAGMAIL1” as evidenced by the msgbox message (seen at bottom left of picture and produced by Line 2 of macro). Yet the Global variable FLAGMAIL1 never changes as noted in the Global Variables window behind everything.



If I change the 3rd line to ph_setglobal_a(“FLAGMAIL1”,0) then all works fine.

Since [LOCAL2] contains the correct value of FLAGMAIL1 then why in the world is it not working?

BTW I have tried quotes and no-quotes around the [LOCAL2] string with no change in results.


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: January 18 2009 at 20:39 | IP Logged Quote TonyNo

LOCAL2 is a Local, not a Global.

Use ph_setvar_a(1,2,0), where 1 means LOCAL, 2 is which LOCAL, and 0 is your value.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
nadler
Super User
Super User


Joined: February 25 2006
Location: United States
Online Status: Offline
Posts: 354
Posted: January 18 2009 at 20:53 | IP Logged Quote nadler

Can I suggest trying ph_setglobal_s( "[LOCAL2]","0").
Also try ph_setglobal_a("[LOCAL2]","0").

If the above don't do what you need to do, try -
ph_setglobal_a(ph_getvar_n(1,2),0)

PH stores all data as strings and converts them to any
data type when it retrieves the data. While that
doesn't explain why your example doesn't work, I have
sometimes run into the same issue, so I switched to the
3rd example and it always works.

Oh another thing I learned the hard way - make sure to
press F5 and save your changes. Exit the macro - go to
another and come back. Sometimes the Local variables
seem to be cached and unless you clear them by exiting
the macro the next time you run the macro it reports the
old value. I thought this was idiosyncratic to my
machine but maybe not.

Back to Top View nadler's Profile Search for other posts by nadler
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: January 19 2009 at 07:12 | IP Logged Quote GadgetGuy

TonyNo - sorry I was not totally clear. The [LOCAL2] variable is the second argument to the subroutine where my problem line of code resides. Thus its use in this case should be valid as I was trying to use [LOCAL2] which contained the name of the GLOBAL variable, to set/clear the GLOBAL variable itself.

Nadler - I had experimented and it appeared that using a quoted ("0") vs an unquoted (0) zero made no difference.

To make long story short, I found the problem.

It was interesting, so I report back here to help anyone else that might encounter such an issue.

In the macro that called my problem macro above, I had pushed a new value to my GLOBAL using ph_setglobal_s("1") [which made the data type a "string"].

Then in the daughter macro above I was trying to use a "numeric" data type.

For some reason PH automatically did the data type conversions OK when the GLOBAL name was used directly, but not so when the name was passed as a LOCAL variable.

Once I discovered this, I changed the calling macro to use the ph_setglobal_a() function, and all is now working smoothly.

{Dave - something to check into in your interpreter?}


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum