novice needs help

Post user created macros to share with others here.

Moderator: Moderators

novice needs help

Postby cudaron on Tue Jan 30, 2007 10:20 pm

Please excuse my 'novice-ness'. :?
I'm trying to write a macro that will loop through an entire file and find a "~" and insert a CR(carriage return) after it.

my feeble attempt went something like:

macro_file UNWRAP;

void UNWRAP()
{
while (!At_Eof)
{
if (Cur_Char == '~') {
right;
CR;
} else {
right;
}

Any help would greatly appreciated. ](*,)
User avatar
cudaron
Registered User
 
Posts: 1
Joined: Tue Jan 30, 2007 8:05 pm

Postby deleyd on Wed Jan 31, 2007 5:22 am

Code: Select all
macro_file UNWRAP;

void move_right()
{
  if (!At_Eof)
  {
    if (At_Eol)
    {
      down;
      goto_col(1);
    }
    else
    {
      right;
    }
  }
}


void UNWRAP()
{
  while (!At_Eof)
  {
     if (Cur_Char == '~') {
        right;
        CR;
     }
     move_right;
  }
}


And if it goes too slow for you, you can add at the beginning of UNWRAP
Code: Select all
refresh=false;
and at the end
Code: Select all
refresh=true;
This will switch off screen updates while it's working.
User avatar
deleyd
Developer
 
Posts: 1023
Joined: Tue Jul 29, 2003 4:27 pm
Location: Santa Barbara, CA

Re: novice needs help

Postby shrike on Thu Mar 04, 2010 1:33 pm

I would do this:

// See Search_Fwd in CMAc Help
While (Search_Fwd("~", 0) ) // find the Tilda Char
{ Right; // go past it
CR; // insert Carriage Return to cause all
} // following text to the new line

Hope this Help's
shrike
Registered User
 
Posts: 18
Joined: Sat Nov 21, 2009 2:36 am


Return to User Created Macros

Who is online

Users browsing this forum: No registered users and 1 guest

cron