Joe_Carrick

Chief Macros - What They Provide

Recommended Posts

A Macro in Chief - basically returns Text to be used in a Label or Text Box.  Internally, the macro can do more but what the user sees is the text output.  In most cases anything internal to the macro is both invisible to the user and can't be used for anything else.

 

Chief provides some predefined macros which they call GLOBAL & Object Specific.  These provide some commonly needed text to be displayed in Labels or Text Boxes.  In no case is that data available to use in another macro - it is simply displayed as text.

 

Even User Defined macros don't (usually) provide data that's available to other macros.  However, Chief provides some data as object attributes that can be accessed and used to calculate values, manipulate text, etc.  That way, additional information can be displayed that is not provided by Chiefs' Global and Object Specific macros.

 

So here's a kicker:  Within a Chief Macro, a special type of variable can be defined.  This is a Ruby Global Variable which is defined simply by using the "$" as the first character of the variable name.  During the same session of Chief any such variable can be used by any macro.  IOW, if a macro creates and uses a variable named TotalDecks it is confined internally to that macro and the value is not available to use in any other macro.  However, if it creates a variable named ($TotalDecks = 235) then another macro can use it as follows:

 

x = $TotalDecks + 115

 

 

resulting in the output of 500

 

This is a relatively simple example but the key is that the data is available to use between macros, allowing more complex output.  It is even possible to access (read and write) information to and from external files, format text, etc.

 

 

Share this post


Link to post
Share on other sites

Joe,

 

It never seems to amaze me how much knowledge you have when it comes to  this and I'm sure other things as well.

 

I tip my hat to you Joe and I give you my utmost respect and I will take upon myself to thank you on behalf of everyone for everything that you contribute on this site, because you are the man to learn from and I'm sure many as myself appreciate everything that you do.

 

With that said, this is way too much for me to apprehend, this programing and all, even that simple macro that Richard and Larry threw it out there, when I was trying to mess with so it would include the text... without your help I doubt if I would got that to work... But in any case programing or not I enjoy reading your every article you post.  

 

Thank you Joe!!!

Share this post


Link to post
Share on other sites

Some guys just have that gift to program. I am not a programmer so I rely on others to do that part for me and I don't mind paying for it. You find your niche (gift) and you stick with it.

 

Joe,

I could be wrong but I'm guessing that you shared with us that knowledge because you are trying to help us better understand macros. I have been researching ruby macros and trying to understand the concept and how it came about and with that information and what you just explained I understand what it is but I still get lost in the equation part of it. I was never good at HTML coding either. You did a very good job explaining it but I will most likely have to rely on other to do the custom stuff for me.

 

Thank You

Share this post


Link to post
Share on other sites

 However, if it creates a variable named ($TotalDecks = 235) then another macro can use it as follows:

 

x = $TotalDecks + 115

 

 

resulting in the output of 500

resulting in the output of 500?? ..or 350?

Share this post


Link to post
Share on other sites

A Macro in Chief - basically returns Text to be used in a Label or Text Box.  Internally, the macro can do more but what the user sees is the text output.  In most cases anything internal to the macro is both invisible to the user and can't be used for anything else.

 

Chief provides some predefined macros which they call GLOBAL & Object Specific.  These provide some commonly needed text to be displayed in Labels or Text Boxes.  In no case is that data available to use in another macro - it is simply displayed as text.

 

Even User Defined macros don't (usually) provide data that's available to other macros.  However, Chief provides some data as object attributes that can be accessed and used to calculate values, manipulate text, etc.  That way, additional information can be displayed that is not provided by Chiefs' Global and Object Specific macros.

 

So here's a kicker:  Within a Chief Macro, a special type of variable can be defined.  This is a Ruby Global Variable which is defined simply by using the "$" as the first character of the variable name.  During the same session of Chief any such variable can be used by any macro.  IOW, if a macro creates and uses a variable named TotalDecks it is confined internally to that macro and the value is not available to use in any other macro.  However, if it creates a variable named ($TotalDecks = 235) then another macro can use it as follows:

 

x = $TotalDecks + 115

 

 

resulting in the output of 500

 

This is a relatively simple example but the key is that the data is available to use between macros, allowing more complex output.  It is even possible to access (read and write) information to and from external files, format text, etc.

Joe

 

I know that you can also build macros in Microsoft excel.

 

Can you tell me the difference between what a macro is and what excel uses to calculate sums? I use math only on a very basic level just enough to do what I need to get the job done but I find myself interested in learning more.

Share this post


Link to post
Share on other sites

Joey - Excel uses formulas to calculate sums.  Now, macros could be used in conjunction with them I imagine (I am not a programmer or that good at advances math).

 

The formula simply tells Excel to add, subtract. divide, multiply numbers in a range of cells.  You do need to know a few of the formatting symbols for some things but it is very basic.

Of course you could make tings much more involved/complicated depending on what you are doing.  I bow out at that point!  ;o)

Share this post


Link to post
Share on other sites

Joey - Excel uses formulas to calculate sums.  Now, macros could be used in conjunction with them I imagine (I am not a programmer or that good at advances math).

 

The formula simply tells Excel to add, subtract. divide, multiply numbers in a range of cells.  You do need to know a few of the formatting symbols for some things but it is very basic.

Of course you could make tings much more involved/complicated depending on what you are doing.  I bow out at that point!  ;o)

 

Excel is one program that I use a lot of. I built an entire estimating program that I use for my business. I started building it with windows 3.0 about 25 years ago and have improved on it over the years. But I only figure out what I really need or want and I keep it as simple as I can. I find that all the estimating programs I have looked at in the past are way to intense and I wouldn't use 90% of the stuff they put in it. I have actually thought about marketing what I have built because of how simple (but not to simple) it is and you can adapt it to whatever type of construction you do but you have to put your own data into it to make it work. So it keeps you stream lined.

 

My Point:

I would like to make my estimating program so it will automatically generate a proposal off of it. I think that I may need to use macros to do it but not sure at this point. That's why I'm so interested in understanding macros.

Share this post


Link to post
Share on other sites

OK, gotcha.  I did the same.  Years ago Shawn McCadden (I think) had a system to do that(proposals) using tools that already exist.

Never really used it and no way I still have the info, unfortunately.  

Share this post


Link to post
Share on other sites

resulting in the output of 500?? ..or 350?

 

I was thinking 350 too , so maybe I'm missing something too.

Share this post


Link to post
Share on other sites

I was thinking 350 too , so maybe I'm missing something too.

Maybe Joe just had a "Brain Fart".

He's very intelligent but still is allowed to make a mistake once and a while.

Share this post


Link to post
Share on other sites

resulting in the output of 500?? ..or 350?

Nice Catch Larry :D

Share this post


Link to post
Share on other sites

OK, so here's the bottom line:

 

Ruby is a pretty basic programming language.  It can perform math operations on numerical data and it can manipulate text data.  In addition, it can store and retrieve data in Hash Tables and Arrays as well as read and write to computer files.  Programming is just understanding the "syntax" and how conditions are handled.

 

The Ruby Syntax is a little different than some other programming languages but IMO is not much more difficult than "Basic" and much easier than a lot of other languages.  Ruby uses what are referred to generally as "methods" but I like to think of as modifiers.  Here are some examples of how a text string can be modified by Ruby:

 

x = "My Text String"

y = x.length --> 14

x = x.upcase --> "MY TEXT STRING"

x = x.downcase --> "my text string"

x = x.gsub("my ","") --> "text string"

x = x + " is now all lower case" --> "text string is now all lower case"

 

if x.length > 14

  y = x.length --> 33

else

 

  x = "Something Else"

end

 

x.rjust(y) -------> "                   Something Else"

 

Now is everyone totally confused?  It's just a matter of making modifications to data. 

Share this post


Link to post
Share on other sites

Yes, confused but getting closer. I guess actually seeing something in action might connect the dots.

Share this post


Link to post
Share on other sites

Never looked at Ruby but from the example above it is not dissimilar from the functions within Excel, just slightly different syntax. All of those text string manipulations and if statements are essentially the same. In Excel the Ruby variables x,y, etc.are the cell coordinates such as A1, B1, etc.

 

If you enter the text string "My Text String" into say cell A1 you have actually made the statement A1="My Text String".

For the length you could in cell B1 enter =LEN(A1) which makes the statement B1=LEN(A1). The displayed result in B1 would be the value 14.

 

=UPPER(A1) converts the text string into uppercase.

=LOWER(A1) converts the text string into lowercase.

 

It may be useful for those wishing to understand Ruby to take a close look at the Excel functions.

 

Graham

Share this post


Link to post
Share on other sites

Some very good information on here just wish I had more time to spend doing some of these things to learn more, hopefully in the slower months I can thanks to all of your imput

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Member Statistics

    27478
    Total Members
    6254
    Most Online
    Oilersfan20
    Newest Member
    Oilersfan20
    Joined