What's new

To Kotori: KScript Editor - some ideas...

kotori

Senior Member
Hi Benjamin,
Thanks for sharing your suggestions. Actually I've been thinking for a long time now about introducing an include/import keyword, but I haven't decided exactly how to implement namespaces. I welcome everyone to share their ideas here.

My editor has auto completion (Ctrl+Space) and call tips (Ctrl+Shift+Space) - I hope you've seen that (although I haven't tested if they work for the new local variables). Regarding using {} for begin and end I'm a little bit hesitant to do that. I tend to think that these special characters are
* not really necessary
* makes the code less readable
* makes the code harder to type
That is why I made the $ and % prefix optional. While {} may be better then using 'end' I still think that python's way of doing it is even cleaner - since the code is indented anyway it uses the indentation determine blocks.

I shall consider making the : in := optional.

Cheers,
Nils
 
some suggestions. I avoid name "class" as it would suggest object oriented implementation could be possible. But at current state, it is not. So "module" or "library" fits more.

Example of a module:
------------------------------------------------------------------------------------------


{ modul_test.ksm => .ksm => Kontakt script module }

module test

... declare i
... declare test

... function testfunction

...... declare i
...... declare test

...... return(2)

... end function

end module


Example of a script:
------------------------------------------------------------------------------------------


{ test.ks => .ks => Kontakt script }

script test

...inlcude "modul_test.ksm"

...on init

...... declare i
...... declare j

...... i = test
...... j = test_testfunction

...end on

...function test

...... declare i

...... return (1)

...end function

end script


compiled:


on init

{ Declarations from script "test" }

... declare $script_test_i
... declare $script_test_j
... declare $script_test_function_test { = return value }
... declare $script_test_function_i

{ Declarations from module "test" }

... declare $module_test_i
... declare $module_test_test
... declare $module_test_function_testfunction { = return value }
... declare $module_test_function_testfunction_i
... declare $module_test_function_testfunction_test


... { function call: i = test }
... $script_test_i:=0
... { return (1) }
... $script_test_function_test := 1
... $script_test_i: = script_test_function_test

... { function call: j = test_testmodule }
... $script_test_j:=0
... { return (2) }
... $script_test_function_testfunction := 2
... $script_test_j: = script_test_function_testfunction

end on


I used test and i and j as often as possible. It's definitly not good code, but: there are no conflicts in namespace. That is what i wanted to show in this dirty example :grin:

as you can see.
 
Hi Nils!

Does _read_persistent_var work in your editor? Is is there a update to those new variables need?

It always says: not declared...
 
Hi Nils!

Does _read_persistent_var work in your editor? Is is there a update to those new variables need?

It always says: not declared...

Hi Benjamin,
yes all new variables and functions in K2.1 should work in the editor. Please try the latest version of the editor, currently (broken link removed). ((broken link removed)).

I wrote a python script to automatically extract all variables and functions from the script manual PDF so I'm pretty sure they are all included. Besides verifying this my tool also found some (minor) errors in the manual which I notified NI of... :smile:

Cheers,
Nils
 
Top Bottom