Forum Discussion

PGSystemTester's avatar
PGSystemTester
Copper Contributor
Mar 24, 2024

MS LOOP Not Preserving Code Syntax

I wrote up a pretty https://answers.microsoft.com/en-us/officeinsider/forum/offinsd_loop-offinsdsub_win/ms-loop-not-preserving-code-initial-line-spacing/d0613dc0-8202-4b3d-ae50-c818c5b6a4aa, but https://www.microsoft.com/en-us/microsoft-loop is modifying code when pasted into its code blocks, ultimately excluding white spaces in lines before readable characters.

 

Basic example showing code in original state:

 

 

 

def fizzbuzz(n):

    if n % 3 == 0 and n % 5 == 0:
        return 'FizzBuzz'
    elif n % 3 == 0:
        return 'Fizz'
    elif n % 5 == 0:
        return 'Buzz'
    else:
        return str(n)

print "\n".join(fizzbuzz(n) for n in xrange(1, 21))

 

 

 

 

When copying the above code from any app (tried several including Notepad) into Loop, the result is below:

Note the lack of indentation on each return line.

 

While this is visually undesirable, it's especially problematic for languages like python given its required spacing syntax.  If one were to then copy the same code BACK from Loop into a Python program, this code would not work.

 

Again the article on other board goes into far more depth, but figured it out to be shown here too.

3 Replies

  • JoeITHelper's avatar
    JoeITHelper
    Copper Contributor
    I cannot access your detail account link due to my documentation. However, reviewing your syntax example, using if, get, call functions the %, ?, / with periods as = the assumption model of reference. That said, if 'a letter' 'what integration asked' to 'define the variable' is an assumption in a training sandbox environment to prevent machine language interference. Best not to loop certain functions.
    • PGSystemTester's avatar
      PGSystemTester
      Copper Contributor
      Thanks for the headsup on the broken link. I believe it's been fixed, but here is the full link: https://answers.microsoft.com/en-us/officeinsider/forum/offinsd_loop-offinsdsub_win/ms-loop-not-preserving-code-initial-line-spacing/d0613dc0-8202-4b3d-ae50-c818c5b6a4aa

      I also think there may have been some confusion as I was referring to the APP Microsoft Loop, not coding a loop (we likely are not the first people to have this conversation, unfortunate to name an app a coding term).
      • JoeITHelper's avatar
        JoeITHelper
        Copper Contributor
        text editor settings, compile settings, app interface connectors. H1 does not equal H2 as H3 compiles H1. White spacing being the question to review.

Resources