Built-In Macro output?


Joe_Carrick
 Share

Recommended Posts

No.  I’ve tried every scenario possible to try and hack those “global” macro values with no success.  I’ve even went so far as to pour through all the various program and data files...at least all those I have the ability to read and understand...and nuthin.  

Link to comment
Share on other sites

25 minutes ago, BrownTiger said:

I assume you are not asking this..

$MyValue = 'stuff to write'

File.open('test.txt', 'w') { |file| file.write($MyValue) }

 

That doesn't work.  The problem is that:

  • $MyValue = "%width%"
  • File.open('test.txt', 'w') { |file| file.write($MyValue) }

simply puts %width% in the file

Link to comment
Share on other sites

11 minutes ago, Alaskan_Son said:

P.S.  I'm sure you probably know this, but we have access to SOME of the various "Global" macros such as time and date, special characters, and room info (in X11), but there are a lot of others we still have no access to.

Yes, but even those are just "STUFFED" text into a Text Box or Label.  Fortunately, Ruby provides us with those things as data by using Ruby Classes and Methods, etc.  It seems CA just provided those "Global" macros internally.  It's the same thing with the Global macro %scale%.

 

I was hoping I could stuff the output into a text file and get usable data - but as you see from my response to Brown Tiger it just puts the %macro_name% in the text file.  When you read that file in Ruby it just executes the built-in macro so the result is no different.

Link to comment
Share on other sites

2 minutes ago, Joe_Carrick said:

Yes, but even those are just "STUFFED" text into a Text Box or Label.  Fortunately, Ruby provides us with those things as data by using Ruby Classes and Methods, etc.  It seems CA just provided those "Global" macros internally.  It's the same thing with the Global macro %scale%.

 

I was hoping I could stuff the output into a text file and get usable data - but as you see from my response to Brown Tiger it just puts the %macro_name% in the text file.  When you read that file in Ruby it just executes the built-in macro so the result is no different.

 

Yep.  I've used that trick to access several values prior to X11 such as room schedule numbers outside the room label (not necessary anymore), but haven't found any way to access any of those non-Ruby macros. 

Link to comment
Share on other sites

BTW,

Many of those "$Globals" are available in Ruby.  Example:

  • $-I = ["D:/Dropbox/Chief Architect Premier X11 Data/Scripts/", "."]

or as attributes of Chief Objects. 

  • Layout Boxes for example have some file names for the Referenced File.
  • These can be useful but it's a matter of discovering where those attributes are located.
Link to comment
Share on other sites

No, that would not be right...

>$MyValue = "%width%"?

 

First it would be the eval function same as in most languages. Second the way it works when software renders an object that contains macro and it sets the instance variables (text/value pairs) execute the macro, collects output goes to the next one. So without this rendering object "%width%" is really meaningless.

 

self.methods.sort <- should give you list of the methods. [self = main ]

global_variables <- should give you global variables

$-I <- returns an array

$-I[0].dup() <- will give you a mutable script directory

This CA Ruby engine at 2.4, the current stable release is 2.6.2. I am not sure what chief is thinking because 2.4 is at the EOL.

 

With X11 - CA started to expose objects vs prior b.s. of string pairs. Hurray. Hopefully they will open the entire hierarchie...

BT

Link to comment
Share on other sites

I recently posted this somewhere else, but it applies here again so...

 

I tell it like this:  People have to look at Chief and Ruby as 2 entirely separate constructs/entities.  Whenever CHIEF sees two % signs enclosing some text, it will display any appropriate automated text.  If that text happens to match a user defined, evaluated text macro then Chief will defer to RUBY to run the code.  RUBY has no clue what anything between percentage signs means though.  Only Chief knows that.  When CHIEF “sees” the percentage signs on screen, Chief either fills it in per the defined macro, leaves it as dumb text, or defers to RUBY.  The only thing Ruby can and ever will do with the text wrapped in % signs is display it as a “%name%” string or error out.  

 

My favorite example is to write a custom evaluated macro with a value of “%layer%” into an object.  You should see the result is what you might expect...it reports the layer of the object.  Now modify the macro to “%layer%”.reverse and see what you get.  In both cases, RUBY is doing nothing more than placing the dumb text on the screen.  CHIEF is the one that replaces the text with something else when the resulting on screen text results in a defined macro (either internal or user defined).  

 

The above is the fundamental reason we cannot access those built in macro values using Ruby.  It's because Chief is the one producing that output.  Ruby has no access to it.  Yes, Chief chooses to allow some things to route through Ruby, but not every macro in Chief is handled like that. 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share