1. modifyindent changes to ed.ex

Hello,

     I just made the changes to ed.ex that Jacques Deschenes
posted earlier this month.  The comment and uncomment feature
works great, and I use it alot in testing procedures.

     I did however have a problem with the indent and unindent features.
When I added the code for the indent and unindent features I received
an error stating that:

single-quote character is empty, so I added a space between the single
quotes.  Now the indent feature works fine, but the unindent feature gives
me the following error:

true/false condition must be an ATOM.

If I remove the space on the line that gives me the error it tells me
the old error that:

single-quote character is empty
            if buffer[i][1] = '' then
                                 ^

I have noticed that the only time I get the ATOM error is if I am
editing a Euphoria source file, such as test.e or test1.ex.
If I am editing a plain file such as ed.doc it works great.

I was wondering if anyone else has had this trouble, or if it is a
conflict with some of the enhancements that I have personally
made to ed.ex

THANKS in advance for any help.

Ferlin.

new topic     » topic index » view message » categorize

2. Re: modifyindent changes to ed.ex

Hi Ferlin,

    To answer your question,
 1) There should be a space betwen the single quote.
 2) I have no problem using indent/undent.
     buffer[i][1]  should certainly be an atom
     and ' ' is certainly an atom too
     so
     if buffer[i][1] = ' ' then
     should not generated the kind of error you report.

I resend the ModifyIndend() procedure to be certain you have it right

----------------------------------------------------------------------------
----------
procedure ModifyIndent(integer action)
-- if action = 1  add a tab at beginning of each line.
-- if action = 0 undent a tab at beginning of each line or if no tab
-- suppress a blanck.

integer first, last, tab, space, BlkCount, LoopCount
sequence inp
   inp = {1,0}
   while inp[1] do
     if action then
       set_top_line("Number of lines to Indent? (+ down, - up) ")
     else
       set_top_line("Number of lines to undent? (+ down, - up) ")
     end if
     inp = value(key_gets(""))
   end while
   if inp[2] = 0 then
     normal_video()
     return
   end if
   if inp[2] < 0 then
     first = b_line + inp[2] + 1
     if first < 1 then
        first = 1
     end if
     last = b_line
   else
     first = b_line
     last = b_line + inp[2] - 1
     if last > length(buffer) then
        last = length(buffer)
     end if
   end if
   inp = {1,0}
   while inp[1] do
     if action then
      set_top_line("Number of blancks to insert? ")
     else
      set_top_line("Number of blancks to remove? ")
     end if
     inp = value(key_gets(""))
   end while
   BlkCount = inp[2]
   if BlkCount < 1 then
     normal_video()
     return
   end if
   if action then  -- indent
     for i = first to last do
       tab = floor(BlkCount/edit_tab_width)
       space = remainder(BlkCount,edit_tab_width)
       buffer[i] = repeat('\t',tab) & repeat(' ',space) & buffer[i]
       buffer[i] = TabsFirst(buffer[i])
     end for
   else -- undent
     for i = first to last do
       LoopCount = BlkCount
       while LoopCount > 0 do
          if buffer[i][1] = ' ' then
             buffer[i] = buffer[i][2..length(buffer[i])]
             LoopCount = LoopCount - 1
          elsif buffer[i][1] = '\t' then
             if LoopCount < edit_tab_width then
                space = edit_tab_width - LoopCount
                buffer[i] = repeat(32,space) & buffer[i][2..length(buffer[i])]
                LoopCount = 0
             else
                buffer[i] = buffer[2..length(buffer[i])]
                LoopCount =  LoopCount - edit_tab_width
             end if
          else
            exit
          end if
          buffer[i] = TabsFirst(buffer[i])
       end while
     end for
   end if
   b_col = 1
   s_col = 1
   set_modified()
   normal_video()
   DisplayWindow(b_line - s_line + 1, 1)
end procedure -- ModifyIndent()

----------------------------------------------------------------------------
-----------
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: modifyindent changes to ed.ex

------=_NextPart_000_01BBDC63.03D0A8E0

Hello Jacques,

     Thanks for the prompt reply to my ModifyIndent problem
I extracted your code from the email and inserted it into the
editor program, and still have the same message:

true/false condition must be an ATOM
     if buffer[i][1] = ' ' then

     I figured if I attached my copy of the editor program to
this message, that perhaps you or someone who has dealt
with Euphoria longer than me could find my problem.

Again the ONLY time it happens is if I am editing a Euphoria
source file, it works great on other documents.

Any help with this would be greatly appreciated.

Thanks in Advance.

Ferlin.
------=_NextPart_000_01BBDC63.03D0A8E0

new topic     » goto parent     » topic index » view message » categorize

4. Re: modifyindent changes to ed.ex

Ferlin wrote:

>     Thanks for the prompt reply to my ModifyIndent problem
>I extracted your code from the email and inserted it into the
>editor program, and still have the same message:

>true/false condition must be an ATOM
>     if buffer[i][1] = ' ' then

to have that error it need that buffer[i][1] be a sequence
I don't see why it should be sequence?

    I ran your version of ed.ex editing syncolor.e and using indent/undent
without
any error.  But I observed that there is a missing space in function TabsFirst()

line:            while find(line[j]," \t" do
there should have a space here-------^

Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu