How to set Xojo code as Xojo Code?

The subject says all…

I’m guessing at what you are asking: if you want to have some text display as code here, such as:

Var  x as String = "abc"
if  (x="pqr")  Then Return

then select it and click on the button that looks like </>

Does not works like your code.

I removed the two quotes at edit time.

Yes, that was what I wanted to ask

Var  x as String = "abc"
if  (x="pqr")  Then Return

Arg! now it worked ! I do not understand…

Look there:

I selected the whole code and only a part is displayed as Code…


I added a new line (Var LoopIdx As Integer) and set the whole as code and this time it worked (more or less).

The Forum software does not like code that start with If ?

Buggy software…

Make sure there is an empty line between the text above your code and the first line of code. It’s a Markdown thing.

1 Like

Thank you Greg.

In the page I wanted to us it, I removed the code, pasted it into TextEdit in Raw format, removed leading spaces, then paste it into the forum Edit part and set it to Code: it worked fine (now).

I noticed that copy/paste code from the docs (including an uRL)… the URL appears in the pasted code.

I deleted it before pressing Reply.

The first bit of code I posted on this new forum suffered from this. The preview showed half my code formatted (starting from the first empty line), even me having selected the whole block. At this time, I didn’t figured it was because of a blank line was needed, so I just thought it was broken and posted it mangled anyway.
Then, I edited my post, because it really looked ugly. Eventually, I figured out the need of a blank line to make it working (I’m still thinking, even right now, that it’s a bug, or, at the very least, a unwanted limitation).

To be totally clear:

Let the first line before the Code blank and add it into the Code lines and you will get all Code lines displayed as Code.

This is not understandable… at first.

Yes, it’s now clear for me (since this first attempt), but the behaviour doesn’t sound right to me… :thinking:

You’d need to talk to the people who came up with the MarkDown formatting as I believe that this is their doing.

Is there’s a doc about this Forum software somewhere to read ?

If you can’t control that on your end, then I’m fine with that. I just thought it was a misconfiguration.