"Enable auto indent on paste" feature and Ctrl-I c

Posted by jadamski413@gmail.com on 28-Apr-2018 15:55

in Progress Developer Studio 11.3 and Classroom 11.7

I need a help - when I type (readable code for me):

  case x:
    when 1 then do:
      x = 2.
    end.
    when 1 then do:
      x = 3.
    end.
  end case.
    
  if x > 0 then do:
    x = 1.
  end.
  else do:
    x = 2.
  end.
and next I press Ctrl-I, I get somethig like this:

  case x:
    when 1 then
      do:
        x = 2.
      end.
    when 1 then
      do:
        x = 3.
      end.
  end case.

  if x > 0 then
  do:
    x = 1.
  end.
  else
  do:
    x = 2.
  end.

Making a copy of my code and pasting it in another place gives the same effect.

This code is completelly unreadable for me.

How can i turrn off this feature or write my own template?

In Procedure Editor (Options -> Editing options -> Language options) I can define DO/END Style

and I have 2 templates: readable "Style 1" and unreadable "Style 2".

Mayby I can't find this settings in Developer Studio ?

All Replies

Posted by Mike Fechner on 29-Apr-2018 02:06

If you have specific formatting requirements, you'll most likely have to turn off most of the Auto .... settings in Progress Developer Studio. It's in the Preferences under Progress OpenEdge -> Editor.

Posted by jadamski413@gmail.com on 30-Apr-2018 03:49

Unfortunately, this does not solve my problem. I will try to explain this (sorry for poor English).
In this example (VIEW NR 1) I have "IF" block (6 first lines).
I want to move (or to copy) it in place where the comment is.

===================================================================
// VIEW NR 1
if xType = 'A' then do:
  xPrice = 1.
end.
else do:
  xPrice = 2.
end.
  find first Customer where Customer.CustName = pCustName no-lock no-wait no-error.
  if avail Customer then do:
    find last Invoice where Invoice.CustId = Customer.CustId no-lock no-wait no-error.
    if avail Invoice then do:
      find first InvoiceItem where InvoiceItem.InvId = Invoice.InvId no-lock no-wait no-error.
      if avail InvoiceIten then do:
        /* Here I'd like to insert an "if" block from the beginning of the procedure */
        if xType = 'B' then do:
          xPrice = 3.
        end.
        else do:
          xPrice = 2.
        end.
      end.
    end.
  end.
===================================================================

I select the first 6 lines, I do Ctrl-X, and in place where the comment is
I do Ctrl-V. After Ctrl-V, I'd like to receive something like this:

===================================================================

// VIEW NR 2
  find first Customer where Customer.CustName = pCustName no-lock no-wait no-error.
  if avail Customer then do:
    find last Invoice where Invoice.CustId = Customer.CustId no-lock no-wait no-error.
    if avail Invoice then do:
      find first InvoiceItem where InvoiceItem.InvId = Invoice.InvId no-lock no-wait no-error.
      if avail InvoiceIten then do:
        if xType = 'A' then do:
          xPrice = 1.
        end.
        else do:
          xPrice = 2.
        end.

        if xType = 'B' then do:
          xPrice = 3.
        end.
        else do:
          xPrice = 2.
        end.
      end.
    end.
  end.
===================================================================

In this example above (VIEW NR 2) block "IF" is properly indented.

But if I turn-off "Enable auto indent on paste", I'll get:

===================================================================

// VIEW NR 3
  find first Customer where Customer.CustName = pCustName no-lock no-wait no-error.
  if avail Customer then do:
    find last Invoice where Invoice.CustId = Customer.CustId no-lock no-wait no-error.
    if avail Invoice then do:
      find first InvoiceItem where InvoiceItem.InvId = Invoice.InvId no-lock no-wait no-error.
      if avail InvoiceIten then do:
if xType = 'A' then do:
  xPrice = 1.
end.
else do:
  xPrice = 2.
end.

        if xType = 'B' then do:
          xPrice = 3.
        end.
        else do:
          xPrice = 2.
        end.
      end.
    end.
  end.
===================================================================

Now, if I press Ctrl-I in indented block I'll get:

===================================================================

// VIEW NR 3
  find first Customer where Customer.CustName = pCustName no-lock no-wait no-error.
  if avail Customer then do:
    find last Invoice where Invoice.CustId = Customer.CustId no-lock no-wait no-error.
    if avail Invoice then do:
      find first InvoiceItem where InvoiceItem.InvId = Invoice.InvId no-lock no-wait no-error.
      if avail InvoiceIten then do:
        if xType = 'A' then 
        do:
          xPrice = 1.

        end.
        else 
        do:
          xPrice = 2.

        end.

        if xType = 'B' then do:
          xPrice = 3.
        end.
        else do:
          xPrice = 2.
        end.
      end.
    end.
  end.
===================================================================

Command Ctrl-I move the "DO:" block to next line, what is unreadable for me.

In the examples above, green color indicates a proper operation

In "ProVision" v 9.1 Procedure Editor has only few options, but veru usefull:
In presented screens this options are set properrly for my needs.
1. (Options -> Editing options) check "Syntax expansion" and "Syntax indent"
2. (Options -> Editing options -> Language options) I can define DO/END Style
My favourite is "Style 1".
I also check options shown in the picture.


This setting causes the Ctrl-C (Ctrl-X) / Ctrl-V combination to work properly


Can I set Developer Studio the same way, also for Ctrl-I keys - so that it does not move the "DO:" block to a new line?

Posted by Sanjeva Manchala on 30-Apr-2018 04:16

Hi,
 
We have seen some issues with indentation when If Then Else statements are present inside the code. In OpenEdge 12.0 we have fixed these issues and gave better options for customers to customize the indentation. Here is the sample screenshot of Indentation preferences from OpenEdge 12.0:
 
 
Hope this helps,
Sanjeev

Posted by Stefan Drissen on 30-Apr-2018 07:26

Just leaving my indentation here:

IF x THEN
   statement1
ELSE IF y THEN
  statement2
ELSE 
  statement3

IF x THEN DO:
   statement1
END.
ELSE IF y THEN DO:
   statement2
END.
ELSE DO:
   statement3
END.

IF x AND
  y
THEN
  statement 1
ELSE IF y AND
   z
THEN
   statement2
ELSE
   statement 3

And I think Python's handling of bad indentation is fantastic (docs.python.org/.../indentation.html)

This thread is closed