From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kjsembed/docs/examples/cmdline/cmdline.js | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 kjsembed/docs/examples/cmdline/cmdline.js (limited to 'kjsembed/docs/examples/cmdline') diff --git a/kjsembed/docs/examples/cmdline/cmdline.js b/kjsembed/docs/examples/cmdline/cmdline.js new file mode 100755 index 00000000..9c96c6cb --- /dev/null +++ b/kjsembed/docs/examples/cmdline/cmdline.js @@ -0,0 +1,78 @@ +#!/usr/bin/env kjscmd + +function list(obj) +{ + println( obj ); + + for ( var i in obj ) { + try { + tp = typeof obj[i]; + + count = 20 - i.length; + spc = ''; + for ( var s=0; s < count; s++ ) + spc = spc + ' '; + + println( ' ' + i + spc + tp ); + } + catch(err) { + println( ' ' + i + spc + 'Error, ' + err ); + } + } +} + +function help() +{ + println(); + println( 'KJSCmd ' + part.versionString + ' Prompt' ); + println( '=======' + '===' + '=======' ); + println(); + println( "Type 'quit' to exit, and 'help' for this text. Anything else" ); + println( 'is evaluated by the KJSCmd engine and the result displayed.' ); + println(); +} + +function cmd_prompt() +{ + System.stdout.print( 'kjscmd> ' ); + return System.stdin.readLine(); +} + +// +// Main +// + +println( "KJSCmd " + part.versionString + " (type 'help' for more information)" ); +done = false; + +do { + + line = cmd_prompt(); + + if ( line == 'quit' ) { + done = true; + } + else if ( line == 'help' ) { + help(); + } + else if ( line == '' ) { + // DO NOTHING + } + else if ( line == null ) { + done = true; + } + else { + try { + output = eval( line ); + + if ( typeof(output) != 'undefined' ) + println( output ); + } + catch(err) { + println( 'Error: ' + err ); + } + } + +} while ( !done ); + +System.exit(0); -- cgit v1.2.3