Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!ll-xn!oberon!pollux.usc.edu!papa From: papa@pollux.usc.edu (Marco Papa) Newsgroups: comp.sys.amiga Subject: FULLY INTERACTIVE SCRIPTS (A Tutorial) Message-ID: <8922@oberon.USC.EDU> Date: 6 May 88 06:14:01 GMT Sender: news@oberon.USC.EDU Reply-To: papa@pollux.usc.edu (Marco Papa) Organization: Felsina Software, Los Angeles, CA Lines: 353 FULLY INTERATIVE SCRIPTS FOR XICON A Tutorial by Marco Papa 'Doc' Now that I am putting the final touches on A-Talk III, the problem has come up of how to create fully interactive scripts for its installation on a Hard Disk and with foreign fonts. The requirement is that the install program must be run from the workbench so that it will work for the non-CLI user as well. Various versions of XICON exist that allow execution of a "script" file from an icon. More than two are available on the Fish disks (Pete Goodeve's is on FF 102) and another version is included in WB 1.3. Both work pretty much the same in the sense that they use the DEFAULT TOOL to invoke XICON and then execute a script with the same name as the icon (save the .info). My requirement is that the user must be able to SELECT among a given set of PREDEFINED options [in the case of fonts for foreign countries] and among a NON-PREDEFINED set of options [ in the case of a hard disk partition name]. It turns out that there is NO command besides ASK that interprets user input. The ASK command just allows one to answer "y" or "n" and returns an different error value in each case. This is OK for yes/no questions, but was no good for my case. I looked at what others had done, and in all cases people have written ad-hoc programs that ask a very specific set of questions. What I wanted was a SIMPLE, SINGLE command that would allow me to use it in all cases I needed. Since I am writing this, you've probably guessed that I have found such a stupid, little program. The program getline.c [appended at the end of this file in source and MANX-compiled binary] gets input from the keyboard, using MANX built in CLI-like line editing, stores the entered data in a buffer and sends the entire string to standard output when the carriage return is pressed. Its use is as follows: echo "where do you want to go [DF0:,DF1:,DF2:] ?" ; getline >RAM:__DUMMY ; cd NIL: con:x/y/w/h/name FROM Install as the last line of the script executed by XICON and include the "interactive" part in the "Install" script. The solution is so simple that I am surprised that nobody came up with it before. Anyway, here is the code and binary for getline.c, plus the 2 scripts files for installing fonts with A-Talk III. The code seemed so small and the problems with the moderated groups so large, that I don't feel bad about posting this. Enjoy. -- Marco Papa 'Doc' #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # getline.c # xicon-install # FD-Install # getline.uue # This archive created: Thu May 5 22:23:16 1988 # By: Marco Papa (Felsina Software, Los Angeles, CA) export PATH; PATH=/bin:$PATH echo shar: extracting "'getline.c'" '(804 characters)' if test -f 'getline.c' then echo shar: over-writing existing file "'getline.c'" fi sed 's/^X//' << \SHAR_EOF > 'getline.c' X/* X * getline.c -- get a line from stdin with "line editing" and send to stdout X * X * Copyright (C) 1988 Marco Papa 'Doc' X * Permission is granted for ANY use of this code if the above notice X * is left intact. X */ X X#include "ctype.h" X#include "stdio.h" X Xstatic char chatbuf[80]; Xstatic short chatindex = 0; X Xmain(argc,argv) X{ X int ch; X X for (;;) { X ch = getchar(); X InputChat(ch); X } X} X XInputChat(ch) Xint ch; X{ X Xchar c; X X c = ch & 0177; X if (iscntrl(c)) { X switch (c) { X case '\n': X FlushChat(); X break; X default: X /* **** throw it away */ X break; X } X } else { /* if not control */ X chatbuf[chatindex++] = c; X } X if (chatindex == 80) FlushChat(); X} X XFlushChat() X{ X int i; X X for (i=0;i 'xicon-install' XATInstall:HardDisk/failat 30 XATInstall:HardDisk/echo "*E[4mSetting up for first time floppy disk installation.*E[0m*N" XATInstall:HardDisk/failat 10 XATInstall:HardDisk/cd ATInstall:HardDisk Xnewcli >NIL: con:0/0/640/200/FloppyDisk from FD-Install SHAR_EOF if test 245 -ne "`wc -c 'xicon-install'`" then echo shar: error transmitting "'xicon-install'" '(should have been 245 characters)' fi echo shar: extracting "'FD-Install'" '(1241 characters)' if test -f 'FD-Install' then echo shar: over-writing existing file "'FD-Install'" fi sed 's/^X//' << \SHAR_EOF > 'FD-Install' Xcd ATInstall:HardDisk Xecho "First time floppy disk installation.*N" Xecho "Warning: this procedure will modify your A-Talk III floppy disk." Xask "Do you want to continue ? [Press RETURN to exit] " X; Xif NOT WARN X SKIP endit XENDIF X; Xfailat 30 X; Xecho "Which county-dependent fonts do you want to install in the" Xecho "A-Talk III disk?" Xecho "[u] USA/UK" Xecho "[s] Swedish/Finnish" Xecho "[d] Danish/Norwegian" Xecho "[g] German" Xecho "[f] French" Xecho "[i] Italian" Xecho "Enter country code [end with RETURN]: " Xgetline >RAM:__ATF <---------------------- [SETUP ***************] X; XIF not exists AT3:fonts X echo "Font directory on Disk 1 (AT3) not found." X echo "Exiting..." X SKIP endit XENDIF X; XIF not exists ATInstall:fonts X echo "Font directory on Disk 2 (ATInstall) not found." X echo "Exiting..." X SKIP endit XENDIF X; XCD ATInstall:fonts XCD nil: SHAR_EOF if test 1241 -ne "`wc -c 'FD-Install'`" then echo shar: error transmitting "'FD-Install'" '(should have been 1241 characters)' fi echo shar: extracting "'getline.uue'" '(6282 characters)' if test -f 'getline.uue' then echo shar: over-writing existing file "'getline.uue'" fi sed 's/^X//' << \SHAR_EOF > 'getline.uue' Xbegin 640 getline XM #\P # ( /' O $ /I #QT[Z JA. XM5?_\2&R ADZZ ,I83RM __PO+?_\80A83V#H3EU.=4Y5__X@+0 (P+P !_ XM&T#__Q M__](@$C 0>R !0@P 4( &<<$"W__TB 2,!@!F$P8 Q@"I"\ XM"F?R8/1@$C L@ )2;( "0>R"2A&M__\ QL %" F8"801.74YU3E7__$*M XM__Q@($AL@)P@+?_\0>R"2A(P" !(@4C!+P%.N@:.4$]2K?_\,"R DC (BW_ XM_+* ;=)(;("<2'@ "DZZ!FY03T*G3KH+6%A/3EU.=4Y5 !(YP@@)&T ""\* XM3KH ,B@ L+S_____6$]G(" $8!13D@CJ , #'#_3-\$$$Y=3G5@UDJ 9_I9 XM@&?D( 1@ZDY5 O"B1M @@4K'J 1E#"\*81I83R1?3EU.=2!24I(0$$B XM2,# O /]@Z$Y5 !(YP@P)&T "! J S / 89PIP_TS?#!!.74YU"*H XM @ ,2JH "&8(+PI.N@@<6$\0*@ ,2(!(P @ =G-D'L@(8F2!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B!L@M9.D$JL@D1G"B\L@D1.N@&>6$]*K(+:9P@@;(+:(*R" XMWDJL@N)G"B\L@N).N@&Z6$]*K(+F9PHO+(+F3KH!JEA/2JR"ZF<*+RR"ZDZZ XM 9I83TJL@NYG"B\L@NY.N@&*6$\L> $""X ! $I9Q0O#4OZ I.KO_B*E]@ XM!D*G\U].2H1M#C L@CY(P+B ; 1*DF82*7P " XM@J)P_TS?!'!.74YU,"H !,!\@ !F""\23KH +EA/0I)P &#@2.=P #0!Q, F XM 4A#QL!(0T)#U(-(0,#!2$!"0-""3-\ #DYU(B\ !"QL@JY.[O_<(B\ !"QL XM@JY.[O^"(B\ !"QL@JY.[O^X+&R"KD[N_\HL;(*N3N[_?"(O 0L;(*N3N[_ XM*$SO 8 !"QL@JY.[O_B+&R"KD[N_\1,[P . 0L;(*N3N[_UD[Z (B+P $ XM+&R"KD[N_Z9,[P . 0L;(*N3N[_T$CG 01,[R" PL;(*J3J[_E$S?((!. XM=4[Z (B;P $+&R"JD[N_F),[P # 0L;(*J3N[_.B)O 0L;(*J3N[^VBQL XM@JI.[O]\(F\ !" O @L;(*J3N[_+B!O 0L;(*J3N[^C"QL@JHB;P $("\ XM"$[N_=@B;P $+&R"JD[N_H9,[P # 0L;(*J3N[^SB!O 0L;(*J3N[^@$SO XM P !"QL@LY.[O^@(&\ !"QL@LY.[O^F(&\ !"QL@LY.[O^R /L XM 0 $ ,> _( /J D@ " @(" @(" @(# P,# P(" @ XM(" @(" @(" @(" @(" @D$! 0$! 0$! 0$! 0$! 0 P,# P,# P,# Q 0$! XM0$! "0D)"0D) 0$! 0$! 0$! 0$! 0$! 0$! 0% 0$! 0$ *"@H*"@H" @(" XM @(" @(" @(" @(" @(" D! 0$ @ $ 0 XM ! 0 $ 0( ! XM XM XM XM XM XM XM XM XH !0 #\@ ^L ! #\@ X Xend SHAR_EOF if test 6282 -ne "`wc -c 'getline.uue'`" then echo shar: error transmitting "'getline.uue'" '(should have been 6282 characters)' fi # End of shell archive exit 0 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= uucp:...!pollux!papa BIX:papa ARPAnet:pollux!papa@oberon.usc.edu "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=