from ipykernel.kernelbase import Kernel
from MDSplus import Data

class MdstclKernel(Kernel):
    implementation = 'Mdstcl'
    implementation_version = '1.0'
    language = 'no-op'
    language_version = '0.1'
    language_info = {
        'name': 'mdstcl commands',
        'mimetype': 'text/plain',
        'file_extension': '.tcl',
    }
    banner = "MDSplus Mdstcl kernel - Tree Command Language interpreter"

    def do_execute(self, code, silent, store_history=True, user_expressions=None,
                   allow_stdin=False):
        if not silent:
            try:
                ans = Data.execute('_status=tcl($1,_out),_out',code)
                status = int(Data.execute('_status'))
                if status & 1:
                    stream_content = {'name': 'stdout', 'text': str(ans)}
                else:
                    stream_content = {'name':'stderr','text': str(ans)}
            except Exception as e:
                stream_content = {'name': 'stderr', 'text': str(e)}
            self.send_response(self.iopub_socket, 'stream', stream_content)

        return {'status': 'ok',
                # The base class increments the execution count
                'execution_count': self.execution_count,
                'payload': [],
                'user_expressions': {},
               }

@@ -570,16 +570,92 @@
    try:%0A
+                lines=code.split('%5Cn')%0A                for line in lines:%0A  
         
@@ -713,14 +713,16 @@
 ut',
-cod
+lin
 e)%0A
+  
     
@@ -771,16 +771,18 @@
 atus'))%0A
+  
         
@@ -816,32 +816,33 @@
                 
+ 
 stream_content =
@@ -871,32 +871,34 @@
 ext': str(ans)%7D%0A
+  
                 
@@ -961,32 +961,47 @@
 rr','text': 
+'%5Cn'.join(line,
 str(ans)
 %7D%0A          
@@ -980,32 +980,33 @@
 in(line,str(ans)
+)
 %7D%0A            ex

handle multiple lines in mdstcl cell