File: prompt.li

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (43 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * @progname       prompt.li
 * @version        None
 * @author         anon
 * @category       
 * @output         booleans and ints function values
 * @description

               miscellaneous prompt functions and procedures
 */

func askny(msg)
{
  set(prompt, concat(msg, "? [n/y] "))
  getstrmsg(str, prompt)
  if(and(gt(strlen(str), 0),
     or(eq(strcmp(str, "y"),0), eq(strcmp(str, "Y"),0)))) {
    return(1)
  }
  return(0)
}

func askyn(msg)
{
  set(prompt, concat(msg, "? [y/n] "))
  getstrmsg(str, prompt)
  if(and(gt(strlen(str), 0),
     or(eq(strcmp(str, "n"),0), eq(strcmp(str, "N"),0)))) {
    return(0)
  }
  return(1)
}

func getintdef(msg, def)
{
  set(prompt, concat(msg, "? [", d(def), "]"))
  getstrmsg(str, prompt)
  if(and(gt(strlen(str), 0),
         gt(index("0123456789",trim(str,1),1),0))) {
    return(atoi(str))
  }
  return(def)
}