Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Smart code for dumb programmers? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: June 01 2020 at 15:56 | IP Logged Quote jeffw_00

Hi - So I discovered that it's possible to create a Jump command
that
looks like

if ({FOO}=1,3,0)

Powerhome doesn't like the idea of Jump 0 - It blocks the queue
forever. I learned my lesson, but perhaps for the benefit of future
dumb programmers - in the next release you might want to add a
check that calls it out as some sort of syntax error?   :-)

I suggest only because it feels like a very small change. Just a
thought.
/j

Edited by jeffw_00 - June 01 2020 at 15:57
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 245
Posted: June 01 2020 at 23:54 | IP Logged Quote gg102

Hi,

While I understand the problem with a jump 0, I would like to offer a word of caution.

Sadly, I admit, I have written a couple of macros where I have used negative jumps.
for example: if (something <> something_else, 2, -10)

I hate this type of programming, but I have run into a situation where for expediency, it was just easier.

My word of caution for Dave is that if doing a test for jump 0, or a jump -1 (depending on the internal
program counter), please don't change negative jumps greater than 1.


I'm probably wrong on this, but I thought that PH had some type of internal iteration counter, and if you
ended up in a tight loop, PH would jump out of the macro by itself.




Back to Top View gg102's Profile Search for other posts by gg102
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 02 2020 at 20:34 | IP Logged Quote dhoward

Unfortunately, I don't really have a way where I could prevent infinite loops as the internal formula processing is handled by a built
in datawindow expression evaluator. I could attempt to analyze code before it is passed to the evaluator but there are so many ways to
create an infinite loop it would be impossible for me to catch them all.

However, what has already been implemented is a "Macro Jump Limit" option in the PowerHome Explorer under PowerHome->Setup->Script. The
default is 0 (infinite) but you can set this value to something that is reasonable for you (be sure and restart or reinit PowerHome for
the change to take effect as this is in the "Setup" section of the Explorer). I tested with 200 and it timed out almost immediately and
would basically limit your macro to processing a maximum of 200 jumps or Goto Label statements.

Another option you have at hand is if you do encounter an infinite loop situation, you can kill it by going to the File menu and
selecting "Clear EXE Queue" so you don't have to completely kill PowerHome to get out of the loop.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: June 02 2020 at 20:56 | IP Logged Quote jeffw_00

Hi Dave - Good to hear from you! "Macro Jump Limit' is just what I
need (as a "safety"), Thanks!

I figured that, as usual, you had already provisioned for this!

Powerhome RULES!

/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 

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