Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Best way to set local variables Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: April 03 2010 at 23:43 | IP Logged Quote MrGibbage

local, temp and global. ph_setvar, ph_getvar and all the other functions like it. What I don't see is a simple way to
assign a local use variable (by local use, I mean visible to the currently running macro and that's it).
ph_setvar(3,19,SOME_VALUE) just isn't all that readable. I really long for a way to have a statement that looks like
SOME_VARIABLE=SOME_VALUE. Am I missing it, or am I just over-reacting?

Skip
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 04 2010 at 21:13 | IP Logged Quote TonyNo

You can use the drop-downs in a macro. Use "SET SYSTEM", then, choose your Local.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: April 04 2010 at 21:25 | IP Logged Quote BeachBum

I’m having a problem understanding the question. If you talking about re-entrant and reusable the same macro runs serially. SOME_VARIABLE=SOME_VALUE is that referring to setting the variable to a variable value?

Edited by BeachBum - April 04 2010 at 21:28


__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: April 04 2010 at 22:20 | IP Logged Quote MrGibbage

In any programming language outside of powerhome, you have statements like I=10, CurrentRow=CurrentRow+1,
or any other similar statements.
Here, we have to use LOCAL1 and then write a function that evaluates to some value. When it
is time to review the program, I have to ask myself, what was LOCAL1 again? Sure, I could
use globals, but that is really messy. No other programming language would say, if you
EVER, in any program, use "I", then you can't use it again.

Even worse is ph_setvar_s(3,33,myfunction). I say worse because in my opinion is is even harder
to read than the set system LOCAL. Again, when I come back to this program, I ask myself,
what was ph_setvar(3,33,...) again???

My question is about readability. The system we have does work. We have local and global
variables, and lots of ways of setting and retrieving values. But in my opinion, it is
messy. One immediate improvement would be if we could change the names of the local
variables. That would actually help out a lot.

Maybe I should work on converting my programs to VB Script??? Has anyone here taken the
time to write a tutorial on how to convert a macro or two into VB Script?

Edited by MrGibbage - April 04 2010 at 22:21
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: April 04 2010 at 22:44 | IP Logged Quote BeachBum

Thank you for clarifying and I totally agree…..

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: April 04 2010 at 23:48 | IP Logged Quote grif091

I put a comment or two in each Macro describing what each variable contains. Not as pretty as a full blown programming language but if you want to program in a language then one of the Script based languages that the Windows Script Host (WSP) supports might be a better choice. VBScript and JScript are supported for sure. Probably more but that is really a WSP question rather than a PowerHome question.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: April 05 2010 at 06:48 | IP Logged Quote MrGibbage

I've been thinking about this, and I think a very real solution to this would be if we could
use any name we wanted for our local variables. What if there was a dropdown in the macro
detail to "DECLARE LOCAL VARIABLE", and then it could have an option for variable type
(string, integer, whatever), and then in the formula area you enter the name of the
variable. Then when you use the set system drop down, the variable should be listed and
usable.
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 17 2010 at 19:44 | IP Logged Quote dhoward

I am looking into this. Wont be in the next beta and wont be able to be quite like requested but Ive been working on a way to do something very similar

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

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