# KScript Editor V1.3.4 with K4 support (including OSX version)



## kotori (Oct 23, 2009)

Hi everyone,

I have updated my script editor/compiler with support and documentation for Kontakt 4 KSP variables, functions and constructs.
:arrow: Download the new version *here* (available for both Windows and OSX)

_Changes_
- Added support and documentation for Kontakt 4 variables/functions
- Added syntax support for the new UI types in Kontakt 4: _ui_switch_ and _ui_slider_
- Made the KSP Reference search more responsive (the result tree is rebuilt quicker)
- Decreased the font size of the KSP Reference tree on OSX 
- Removed the usage of non-default font families in the KSP Reference on Vista in order to fix a problem where the ends of entries were visually cut-off
- Updated the version of the parsing library used (shouldn't affect anything else than perhaps compilation speed)

If you find anything wrong please let me know.
_Edit:_ and if the new K4 functions work fine, then by all means feel free to let me know of that too. I plan on posting a link on the NI forum once it hasòP×   ´òP×   ´óP×


----------



## Freesamples (Oct 23, 2009)

Yeaaaaaah! Wow!!! THANKS a lot Nils!!!


----------



## Big Bob (Oct 23, 2009)

*Re: KScript Editor V1.3.3 with K4 support (including OSX version)*

Hi Nils,

Welcome back from your (ahem) sabatical o=< And of course we're all thrilled to get the KScript update (especially Benjamin I'll bet) :D 

God Bless You My Friend.

Bob


----------



## Thonex (Oct 23, 2009)

*Re: KScript Editor V1.3.3 with K4 support (including OSX version)*



Big Bob @ Fri Oct 23 said:


> Hi Nils,
> 
> Welcome back from your (ahem) sabatical o=< And of course we're all thrilled to get the KScript update (especially Benjamin I'll bet) :D
> 
> ...



Speaking of sabbaticals.... how have *YOU* been my friend???

Hope all is well.

Cheers,

AK


----------



## Big Bob (Oct 23, 2009)

*Re: KScript Editor V1.3.3 with K4 support (including OSX version)*

Hi Andrew,

I know I've been kind of scarce these days also but I'm still hanging around *loosely* :lol: 

I'm in the middle of a very lengthy move and my studio is completely torn down. It probably won't be back up for another couple of months yet (provided I can stay alive that long :roll: ). Hopefully I'll be back up and running before K5 ~o) 

Now that you have released LASS are things going to settle down a little with you? Or, are you now busier than ever? Whichever, just remember to take time to smell the roses my friend.

God Bless,

Bob


----------



## kotori (Oct 24, 2009)

*Re: KScript Editor V1.3.3 with K4 support (including OSX version)*

I noticed that several K3 functions have been renamed in K4 and the initial underscore removed (or rather made optional, since it seems that the old variants are still accepted, although undocumented). I have now issued a small update to account for this.

:arrow: *Download KScript Editor V1.3.4*

----

Hi Bob,
Great to see you around here. Moving seems laborious. Please take care with that so that you don't overstrain yourself. I hope you're moving someplace nice.  

Cheers,
Nils


----------



## polypx (Oct 24, 2009)

Nils --- I get a "file not found" on the Mac version link.

???


----------



## kotori (Oct 24, 2009)

polypx @ Sat Oct 24 said:


> Nils --- I get a "file not found" on the Mac version link.


Oops. It's fixed now. Thanks for the heads up.


----------



## Big Bob (Oct 24, 2009)

*Re: KScript Editor V1.3.3 with K4 support (including OSX version)*

Hi Nils,



> Hi Bob,
> Great to see you around here. Moving seems laborious. Please take care with that so that you don't overstrain yourself.



Now you tell me! :lol: I can now say for a fact that no one as old as me should ever even attempt to move :roll: 



> I hope you're moving someplace nice.


We're just moving across town but it is a much nicer section of Apple Valley.

Take Care My Friend,

Bob


----------



## Frederick Russ (Oct 24, 2009)

Great Job Nils, thanks!


----------



## kotori (Oct 25, 2009)

Benjamin reminded me of the fact that I forgot to mention a new feature. It seems that Kontakt 4 has some new functionality that lets you link a script slot to a text file containing the source code making it possible to update the script source without copying and pasting code to Kontakt (which can be slow with large scripts).

The new KScript Editor version supports outputting the compiled result to a text file of ones choice (in addition to automatically placing it on the clipboard like it currently does). See the example below.


```
on init 
  {#pragma save_compiled_source D:\Program files\Native Instruments\Kontakt 4\test.txt}
  set_script_title('test')
end on
```

If the file already exists it will be silently overwritten. In order to hinder that any important file is inadvertently overwritten I decided for safety reasons to impose some limits on the format of the file path: it must be an absolute (full) path containing "Native Instruments" and "Kontakt 4" and ending with ".txt".


----------



## Dynamitec (Oct 25, 2009)

Ooops, I just noticed that I haven't replied to this thread yet (I already thanked Nils in our email conversation). But it might look strange, because I was asking for an urgent KScript Editor update to support K4 compatibility. 

So: thanks again, Nils!

Btw. funny that Nils KScript Editor update threads almost always bring together all the guys from the beginning of this forum  Only Nickie haven't replied yet.


----------



## Nickie Fønshauge (Oct 25, 2009)

No, I don't pop in very often these days. 

I am glad to see you back Nils; I was getting a wee bit worried by your long absence.

I haven't upgraded to K4 and won't do it for a good while to come, but nevertheless it is great to know, that you still support Kontakt with your editor. Thank you so much for that! I shudder by the mere thought of writing scripts for Kontakt without the KScript Editor.


----------



## Thonex (Oct 31, 2009)

Hi Nils,

A quick question for you.

Is there a way to make the text only in the Callbacks and Functions area larger? On my Mac Book Pro they are so tiny I really have to squint to be able to read it.

Thanks,

Andrew K


----------



## Hans Adamson (Oct 31, 2009)

Thanks Nils,

I am definitely going to try and start using your editor now. Are here any help files or other information about its usage? I am basically starting from scratch since I have only used one of your very first versions as a text editor. I understand the current editor offers sophisticated shortcuts and "simplifications" to the scripwriting process?

Best,
Hans


----------



## Nickie Fønshauge (Nov 1, 2009)

Hans, there is some documentation of the editor on http://nilsliberg.se/ksp/scripts/tutorial/editor.html. It covers the essentials.


----------



## Hans Adamson (Nov 1, 2009)

Nickie Fønshauge @ Sun Nov 01 said:


> Hans, there is some documentation of the editor on http://nilsliberg.se/ksp/scripts/tutorial/editor.html. It covers the essentials.


Thanks Nickie,

I see I've got some reading to do.


----------



## kotori (Nov 2, 2009)

Now version 1.3.5 (the latest) is available for OSX too.


----------



## Bo Clausen (Nov 3, 2009)

Hej Nils

First a very big thank you for making this great Editor even better.

A very little thing, that only is graphical, so not a big problem:

If I make a text_line/set_text , then "on,end,if,while,release,select -" gets highlighted (blue).

Best regards
Bo

Ps: I'm using PC


----------



## kotori (Nov 3, 2009)

Hej Bo,

What you see is due to the fact that by default I use a syntax highlighter designed for Pascal, but with the keyword list customized. However, in Pascal strings are written within apostrophes - not quotation marks. What you can do is to either write strings like 'this' instead of "this" (the compiler will translate it to regular KSP syntax) or you can turn on the "Folding and extended syntax highlighting" in the Settings menu. The latter option can cost some performance when opening new files though. 

Cheers,
Nils


----------



## Bo Clausen (Nov 3, 2009)

kotori @ Tue Nov 03 said:


> - or you can turn on the "Folding and extended syntax highlighting" in the Settings menu.



Ah - thanks, that did the trick.  

I must have had this turned on in v.1.3.1 and earlier, cause then I didn't see this problem.

-Bo


----------



## kotori (Nov 3, 2009)

Bo Clausen @ Tue Nov 03 said:


> Ah - thanks, that did the trick.
> 
> I must have had this turned on in v.1.3.1 and earlier, cause then I didn't see this problem.



Yes, I moved the path to the KScript Editor settings file in one version, so you may have lost the setting at the time of that change.



Thonex @ Tue Nov 03 said:


> Hi Nils,
> 
> Just in case you missed this question the first time....



Hi Andrew,
I have updated the V1.3.5 file for OSX. Please download it (same url as before, but a new file). I hope the font sizes will be more sensible now.

-Nils


----------



## Thonex (Nov 3, 2009)

kotori @ Tue Nov 03 said:


> Hi Andrew,
> I have updated the V1.3.5 file for OSX. Please download it (same url as before, but a new file). I hope the font sizes will be more sensible now.
> 
> -Nils



It works brilliantly!!! Thanks Nils!!

You are the Master of Your Domain!!!! :D 

Cheers, o-[][]-o [/i]

Andrew K


----------



## kotori (Nov 4, 2009)

By mistake I introduced a bug when introducing the pragma directive. In case you use comments containing extended ascii characters (like, å ä ö ü etc) and have any problem compiling your code then please upgrade to the latest version of KScript Editor. I also made some other changes, see below:

_Changes_
 Fixed a bug that caused the compiler to halt when encountering comments containing extended ascii characters.
 Separated the Advanced syntax highlighting and Folding into two separate settings. Folding is for some reason slightly slower than the advanced syntax highlighting so this makes it possible to have the latter on without suffering the performance hit of the former.
 Added an option to the settings menu which when active makes the compiler report if-statements and case-statements with empty (or commented out) bodies. Due to a Kontakt bug such statements silently cause the equivalent of an invokation to the exit function to occur, without any error being reported by Kontakt. This new optional check is only performed if "Extra syntax checks" is also activated.
Here is a sample script that illustrates the two cases identified by the new bug-checker:

*function* test
``_{ body of function has been commented out }_
*end function*

*on init*
``*if* 1=1
````test
``*end if*
``
``*select* NUM_GROUPS
````*case* 1
``````test
``*end select*
``
``message('we never come far enough to see this message')
*end on*

Both these invokations of the test function would be equivalent to a call to the exit function due to the fact that Kontakt is unable to handle compound statements with empty bodies in these cases. This Kontakt bug seems to affect all versions from Kontakt 2 to Kontakt 4. As the example above shows it is often not readily apparent that there are zero statements because of the inlining of user-defined functions, so without this new check it's easy to get bitten by this problem.


----------

