readLine.js revision 802:235d22ccfd24
1206378Srpaulo#// Usage: jjs -scripting greeting.js 2206378Srpaulo 3206378Srpaulo/* 4206378Srpaulo * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 5206378Srpaulo * 6206378Srpaulo * Redistribution and use in source and binary forms, with or without 7206378Srpaulo * modification, are permitted provided that the following conditions 8206378Srpaulo * are met: 9206378Srpaulo * 10206378Srpaulo * - Redistributions of source code must retain the above copyright 11206378Srpaulo * notice, this list of conditions and the following disclaimer. 12206378Srpaulo * 13206378Srpaulo * - Redistributions in binary form must reproduce the above copyright 14206378Srpaulo * notice, this list of conditions and the following disclaimer in the 15206378Srpaulo * documentation and/or other materials provided with the distribution. 16206378Srpaulo * 17206378Srpaulo * - Neither the name of Oracle nor the names of its 18206378Srpaulo * contributors may be used to endorse or promote products derived 19206378Srpaulo * from this software without specific prior written permission. 20206378Srpaulo * 21206378Srpaulo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22206378Srpaulo * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23206378Srpaulo * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24206378Srpaulo * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 25206378Srpaulo * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26206378Srpaulo * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27206376Srpaulo * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28206376Srpaulo * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29206376Srpaulo * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30339161Skevans * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31339161Skevans * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32339161Skevans */ 33339161Skevans 34339161Skevans// readLine prints prompt and reads user response 35293724Ssmhvar name = readLine("Your name please: "); 36293724Ssmh 37206376Srpaulo// user name is interpolated within string 38280950Sandrewprint("Hello ${name}"); 39206376Srpaulo