Author Topic: My macro runs on my system, not on my co-worker's system  (Read 7368 times)

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
My macro runs on my system, not on my co-worker's system
« on: June 20, 2007, 01:22:47 am »

I've written a macro- which my coworker wants to use.
However, it doesn't run as expected on his system (but it runs perfectly on my system).

When we load/run the macro on my co-worker's system, we immediately see the message
"Finished preprocessing all open files!"

displayed. It never iterates through the open buffers on his system. We usually try this with 30 or so files, so it takes 10-20 seconds.

On my system, I can see it iterating through all the open files/buffers, as well as see the names displayed of the files that do not have a .C or .H extension.



When I remove this line  (and the associated else and {} )

   if ( (stricmp(fileExt, "c") == 0) || (stricmp(fileExt, "h") == 0) )


the macro runs on his system.

We are both using SlickEdit 12.01, and and using XP SP2.

What could cause this anomaly?
Thanks

void My_SelectiveDisplay_Callback()
{

_str fileExt;

   fileExt = pcextension(p_buf_name);

   // process .C and .H files only
   if ( (stricmp(fileExt, "c") == 0) || (stricmp(fileExt, "h") == 0) )
   {

      message("Preprocessing " strip_filename(p_buf_name,"PD"));           
      preprocess( " -w TRUE=1 FALSE=0 symbol1=1 symbol2=0 symbol3=1"); // arg is usually much longer
      message("Finished preprocessing " strip_filename(p_buf_name,"PD"));   
   }
   else
   {
      message("Not a valid file type -> " strip_filename(p_buf_name,"PD"));   
   }
}

//******************************************************************************************

_command void MyPreprocess() name_info(',')
{
   for_each_buffer('My_SelectiveDisplay_Callback');
   message("Finished preprocessing all open files!")
}

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: My macro runs on my system, not on my co-worker's system
« Reply #1 on: June 20, 2007, 07:56:21 am »
I didn't try it by myself, but it seems that this
Quote
fileExt = pcextension(p_buf_name);
is not the appropriate method to get the file extension b/c pcextension is intended to be used by fileman.
I'd propose to use _bufname2ext which also catches 'referring' extensions.

Hope it helps,
HS2


cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: My macro runs on my system, not on my co-worker's system
« Reply #2 on: June 20, 2007, 02:16:29 pm »
I didn't try it by myself, but it seems that this
Quote
fileExt = pcextension(p_buf_name);
is not the appropriate method to get the file extension b/c pcextension is intended to be used by fileman.
I'd propose to use _bufname2ext which also catches 'referring' extensions.

Hope it helps,
HS2




Thanks. I will try _bufname2ext, but would like to better understand why I get the expected results on my system, but not on my coworker's system.



hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: My macro runs on my system, not on my co-worker's system
« Reply #3 on: June 20, 2007, 03:30:49 pm »
See the comment of the pcextension fct.
Quote
Returns extension from fileman_line without the dot.
fileman_line must be in the column format of the file manager.

I wonder that your method was working with p_buf_name as argument...
Maybe your coworker uses another project dir which just reveals the bug mentioned above.

HS2

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: My macro runs on my system, not on my co-worker's system
« Reply #4 on: June 20, 2007, 05:26:12 pm »
See the comment of the pcextension fct.
Quote
Returns extension from fileman_line without the dot.
fileman_line must be in the column format of the file manager.

I wonder that your method was working with p_buf_name as argument...
Maybe your coworker uses another project dir which just reveals the bug mentioned above.

HS2

I read the docs for pcextension before using, but don't understand what is meant by the "column format", and "file manager"
I haven't been done much with Slick macros- in fact, I'm revisiting the project I had started on back in January.

As far as p_buf, is it not a string? I think someone replied to a question, when I asked about iterating over all of the files in the project.

As far as the project dir goes- nothing in my macro is directory specific- at least as far as the code I've written.
Maybe there's something that gets stuck in the .ex file- that has something to do with the directory.
I'm just iterating over all the open files, but filtering out everything that is not .C and .H


hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: My macro runs on my system, not on my co-worker's system
« Reply #5 on: June 20, 2007, 05:40:36 pm »
fileman is a special feature which could be very useful e. g. for (interactively) applying a (user) macro comand to a set of files etc. Try it by invoking 'Files-> File manager'.
A lot of features offered by fileman rely on it's (self-)generated and well formatted file lists.
p_buf_name is just the (unformatted) buffer name hence fileman related functions as pcextension() and friends are likely to fail since they expect a formatted file list line as argument.

HS2

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: My macro runs on my system, not on my co-worker's system
« Reply #6 on: June 20, 2007, 05:50:41 pm »
fileman is a special feature which could be very useful e. g. for (interactively) applying a (user) macro comand to a set of files etc. Try it by invoking 'Files-> File manager'.
A lot of features offered by fileman rely on it's (self-)generated and well formatted file lists.
p_buf_name is just the (unformatted) buffer name hence fileman related functions as pcextension() and friends are likely to fail since they expect a formatted file list line as argument.

HS2

Fileman looks like it has some powerful features, but when I told it to display *.*, it displayed the files form the current directory.

My project file contains all of the .cc files I will invoke my macro on, but are in another directory.
I've designed my macro to iterate over just the open files (buffers). If I open all of the .C files in the project,  Slick hangs (probably because too much memory is consumed).

I can live with this- and it makes it easier for the user to just look at a few files that have been preprocessed with my macro, and learning the intricacies of fileman at this point, is likely to slow my progress down.

So If p_p_buff_name is not the right arg to use, I will have to find another.


thanks

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: My macro runs on my system, not on my co-worker's system
« Reply #7 on: June 20, 2007, 05:57:59 pm »
I didn't try it by myself, but it seems that this
Quote
fileExt = pcextension(p_buf_name);
is not the appropriate method to get the file extension b/c pcextension is intended to be used by fileman.
I'd propose to use _bufname2ext which also catches 'referring' extensions.

Hope it helps,
HS2

_bufname2ext is not in the helpfile. Is this a typo by any chance?
Is this a function, or just a string variable?

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: My macro runs on my system, not on my co-worker's system
« Reply #8 on: June 20, 2007, 06:05:57 pm »
Hmm - seems that I found it by rev-engineering Slick sources...
It's a fct. and it's defined here:
stdprocs.e
Code: [Select]
// Returns referred extension for buffer name, using refer_ext
_str _bufname2ext(_str &buf_name)
{
   return refer_ext(_file_case(get_extension(buf_name)),buf_name);
}

BTW: You could try the 'fp' command on cmdline to find a Slick-C fct./command (e.g. 'fp _bufn').

HS2
« Last Edit: June 20, 2007, 06:08:23 pm by hs2 »

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: My macro runs on my system, not on my co-worker's system
« Reply #9 on: June 20, 2007, 06:18:45 pm »
Hmm - seems that I found it by rev-engineering Slick sources...
It's a fct. and it's defined here:
stdprocs.e
Code: [Select]
// Returns referred extension for buffer name, using refer_ext
_str _bufname2ext(_str &buf_name)
{
   return refer_ext(_file_case(get_extension(buf_name)),buf_name);
}

BTW: You could try the 'fp' command on cmdline to find a Slick-C fct./command (e.g. 'fp _bufn').

HS2

Ok- all of this stuff is new to me. I don't know where things are or what to look for, if it's not in the helpfile.

I  need to pass an argument to _bufname2ext(). If p_buf_name shouldn't be used, what is the name of the buffer for any given file?

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: My macro runs on my system, not on my co-worker's system
« Reply #10 on: June 20, 2007, 06:28:57 pm »
You can use _bufname2ext ( p_buf_name );.
I tried to explain that 'p_buf_name' is not the appropriate argument for (fileman-related) fct. pcextension().
Maybe my posting was a bit confusing ... sorry.

HS2