Author Topic: Programmatically retrieving/setting Config Variables in Slickedit 2008  (Read 9537 times)

Bacher

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
I need to grab/set the value of a Config Variable programmatically, but can't figure out how to do it.

the variables I need are def_auto_linecomment and def_extend_linecomment

I've tried:

bool original_auto_linecomment = get_var(find_index('def_auto_linecomment', VAR_TYPE));
bool original_auto_linecomment = get_var('def_auto_linecomment')

as well as other variations.  I feel like I'm really missing something simple...

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Programmatically retrieving/setting Config Variables in Slickedit 2008
« Reply #1 on: August 28, 2008, 02:01:36 AM »
Did you try _get_var instead of get_var?
(Note the leading underscore).

Code: [Select]
bool original_auto_linecomment = _get_var(find_index('def_auto_linecomment', VAR_TYPE));
//                               ^ you need the leading underscore

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Programmatically retrieving/setting Config Variables in Slickedit 2008
« Reply #2 on: August 28, 2008, 01:04:31 PM »
If your in macro code def_auto_linecomment is a macro variable, so you can just do this:
Code: [Select]
boolean original_auto_linecomment = def_auto_linecomment;
If your writing DLL code, then it's a little more complicated to get a macro var.

Bacher

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Programmatically retrieving/setting Config Variables in Slickedit 2008
« Reply #3 on: August 28, 2008, 04:51:47 PM »
   boolean original_auto_linecomment = _get_var(find_index('def_auto_linecomment', VAR_TYPE));

results in: _get_var complaining about Expecting constant expression within it's ()

   boolean original_auto_linecomment = def_auto_linecomment;

results in: Identifier 'def-auto-linecomment' not declared

As far as I know this is normal macro code, it's something that's meant to be loaded in Macro->Load Module and is used to define helper functions to key commands.  It was written for older versions of slickedit and I'm trying to port it to the latest version.  It originally had extern bool def_auto_linecomment, but that was producing compile errors that only functions can be defined extern.

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Programmatically retrieving/setting Config Variables in Slickedit 2008
« Reply #4 on: August 28, 2008, 06:44:27 PM »
This line you quoted compiles fine for me, and executes fine for me:
Code: [Select]
boolean original_auto_linecomment = _get_var(find_index('def_auto_linecomment', VAR_TYPE));

This line you quoted might need a #import near the top of the macro file:
Code: [Select]
// def_auto_linecomment is from box.e, so if the variable can't
// be found, try #import'ing the file and see if that helps.
#import "box.e"

boolean original_auto_linecomment = def_auto_linecomment;


By the way, what version of SE was the macro working in before, and what version of SE are you trying to get it working in?

Bacher

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Programmatically retrieving/setting Config Variables in Slickedit 2008
« Reply #5 on: August 28, 2008, 08:28:49 PM »
Tried the #import "box.e", and it complains here:

   boolean original_auto_linecomment = def_auto_linecomment;

Saying: Expected constant expression.

The version of slickedit this code worked on that I'm porting from is 12.0.3 and my version is 13.0.2.0.

If the same code is working on other people's v13 slickedit's then it suggests that I might have some code earlier confusing the macro language.