Multiple instances of newLISP-tk (Auto-configuration)

Q&A's, tips, howto's
Post Reply
HPW
Posts: 1377
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Multiple instances of newLISP-tk (Auto-configuration)

Post by HPW »

In the help is a description how to run multiple instances of newLISP-tk.
But this is not a good way for end-users.
So with a little mofification of newLISP-tk it is possible to do it with TCL.

Code: Select all

# global variables
....
set sessionId 1                   ;#Number 1 to start session counting
set sessionCur 0                  ;#Number of running session
By the way: newLISPpid is twice in the varlist!!

Code: Select all

proc ExitProc {} {

	global nlio TCLTKsock TCLTKlisten newLISPpid sessionId Ide
	catch { close $nlio }
	catch { close TCLTKsock }
	catch { close TCLTKlisten }
	set tdir $Ide(TempDir)
	append tdir "/newlisp" $sessionId ".log"
	if {[file exists $tdir] == 1 } {file delete $tdir}
	catch { exec kill $newLISPpid }
	}

Code: Select all

########### Start newLISP in port server mode to handle requests from Tcl/Tk ##############

# start local copy of newLISP only if running newLISP and newLISP-tk on the same host
# else assume that newLISP already has been started at the remote $Ide(NewLISPhost)
if { $remoteFlag == 0 } {
	while { $sessionCur == 0 } {
		set tdir $Ide(TempDir)
		append tdir "/newlisp" $sessionId ".log"
		if {[file exists $tdir] == 0 } {
			set sessionCur $sessionId
			set logFile [open $tdir w]
			puts $logFile "# newLISPX.log"
			append sessionline "# This file is generated by session: " $sessionId
			puts $logFile $sessionline
			puts $logFile "#\n"
			close $logFile
			} else {
			set sessionId [expr $sessionId + 1]
			set Ide(newLISPport) [expr $Ide(NewLISPport) + 2]
			set Ide(TCLTKport) [expr $Ide(TCLTKport) + 2]
			}
		}
	set newLISPpid [exec newlisp -p $Ide(newLISPport) &] }

# connect to newLISP
Now you can start newlisp as often as you like.
Hans-Peter

Post Reply