# Posting script code in forums



## Thonex (Apr 20, 2006)

WOW Nils!!!!!

Sex on a plate!!!!!!

Can't wait until the new version is released.

Thanks for doing this!

Cheers,

T


----------



## ComposerDude (Apr 20, 2006)

Nils, fantastic idea!

Maybe...perhaps we could prevail upon Frederick to have his programmer (who has already modded lots of the forum code) tweak this to turn off whitespace condensing. I mean, after all, some code somewhere IS changing what we type, and that code needs to be made less aggressive regarding spaces, at least if it's in a monospaced font.

The underline idea is clever but as you point out it makes code unusable as-is. Does your editor yet have a function to "de-underline" imported code with one command? (I'm sure it will, now, in about 2 minutes!) It could distinguish between white underlines used for spacing versus other-color underlines legitimately allowed as part of function and variable names (e.g. "add_menu_item", "which_note").

BTW let me congratulate you on the syntax-coloring script editor, just in general. I use similar editors for writing code and they can make life so much easier, so thank you for extending the functionality to Kontakt scripting!

To others: a well-designed editor program in itself is "nontrivial", and adding the syntax coloring means that the editor must be aware of and analyzing the language _as you type it in_. This can be a lot of work and Nils is very generous to make this available for free.

-Peter


----------



## Frederick Russ (Apr 20, 2006)

This is the best I can do for now:
A[tab]B
AAAAB

Not quite perfect but it may work for your purposes.


```
A[tab]B
```

In the meantime I can check with the programmer. Don't want to promise anything but I can ask.

edit: actually there is no space before 'tab' - for some reason the code feature skewed it.


----------



## sbkp (Apr 20, 2006)

Usually the "nbsp" entity is used for repeated spaces in HTML. I have no idea if the forum software allows that, though. Let's see:

A&nbsp;&nbsp;&nbsp;B

Well, crap. You need this, apparently, Frederick:

http://www.phpbb.com/phpBB/viewtopic.php?t=190144


----------



## Big Bob (Apr 20, 2006)

Hey Nils,

You are a marvelous asset to the K2 community and a blessing to have around.

God Bless,

Bob


----------



## kotori (Apr 20, 2006)

Wow, thanks guys for the encouragement. That's quite some response! :shock:  

Regarding the space problem there doesn't seem to be any solution using the existing BBCode. There's is however a BBCode mod that allows you to write [spacer=3] to generate three hard spaces.
Maybe I could use [tab.] instead but both I and Bob use an indentation width of two spaces whereas [tab.] uses four spaces. So comments and continued lines could get incorrectly aligned. Maybe it's still the best solution though. Unfortunately the NI forum doesn't seem to support [tab.]. :???:

By having a quick look at some mods it seems BBCode isn't very modular. That's to bad, because otherwise it wouldn't be terrible difficult to write php code that added a [script] tag which did all the syntax highlighting itself.


----------



## kotori (Apr 20, 2006)

ComposerDude @ Thu Apr 20 said:


> a well-designed editor program in itself is "nontrivial", and adding the syntax coloring means that the editor must be aware of and analyzing the language _as you type it in_. This can be a lot of work and Nils is very generous to make this available for free.
> 
> -Peter



Hi Peter,
actually I cheated in this case. I didn't write the syntax coloring, instead I use the built-in pascal lexer in the editing component that I use (scintilla) but with a custom list of keywords. That's why the editor insists on highlighting things inside strings - the pascal syntax differs by writing strings inside ' instead of ". Other than that everything works very nicely though and K2 scripts are a bit similar to pascal.


----------

