HP3000-L Archives

October 1997, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jeff Vance <[log in to unmask]>
Reply To:
Jeff Vance <[log in to unmask]>
Date:
Fri, 3 Oct 1997 11:30:54 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (108 lines)
Hi Joe,

Thanks for sharing your samba script.  I am replying to show a few
ways that some of the CI statements you use can be done differently --
not necessarily better -- just an alternate way.

regards,
Jeff Vance, CSY

On Oct 3,  7:03am, Joe Whitlock wrote:
> :print sambapr.cmdfiles;page=0
> COMMENT ********************************************************
On 5.5 and later you can use a '#' in place of COMMENT, eg:
#    SAMBA PRINT TO
...
> WHILE(TRUE)
...>
>
> ECHO ![CHR(27)+'H'+CHR(27)+'J'+CHR(13)]
I like your use of ![chr(27)] for embedded ESCs
...
> ECHO 1.  !PRINTER1  !LOCATION1
> ECHO 2.  !PRINTER2  !LOCATION2
...
> ECHO 15. !PRINTER15  !LOCATION15
The above echos could be relaced by a loop like:
   setvar i 0
   while setvar(i,i+1) <= 15 do
      echo !i.  !"printer!i"   !"location!i"
   endwhile

Alternatively, my echo above could be changed to:
      echo !i.  ![printer!i]   ![location!i]

> WHILE (!I < 1 OR !I > 15 ) DO
You don't need to explicitly reference I (!I) in an expression unless I is a
parameter.  In this while expression you could write:
  WHILE (I < 1 OR I > 15 ) DO

>   ECHO
>   INPUT NAME=I;PROMPT="ENTER THE PRINTER OPTION NUMBER OR [Q]:"
In 5.5 express 3 you will be able to specify the number of byte you want
INPUT to read.  Note: INPUT always creates a STRING var, regardless of the
data entered by the user.

>   IF ( ALPHA('!I') ) THEN
Here var I is of type string (due to above INPUT cmd) so the '!I' is not
needed. You could also write:
   if alpha(i) then...  or since I is a string you could write:
   if ups(i) = 'Q' then...

>     SETVAR I UPS('!I')
>     IF ('!I' = 'Q') THEN
>       RETURN
>     ENDIF
>     ECHO SELECT A NUMBER BETWEEN 1-15
>     SETVAR I 0
>   ELSEIF ( NUMERIC('!I') ) THEN
>     IF ( !I < 1 OR !I > 15) THEN
Here you need '!i' since you are converting i from a string to an int.

>        ECHO SELECT A NUMBER BETWEEN 1-15
>     ENDIF
>   ELSE
>     ECHO SELECT A NUMBER BETWEEN 1-15
>     SETVAR I 0
>   ENDIF
> ENDWHILE
An alternate implementation to validating user input could be:
 while not (bound(printer![setvar(i,ups(input( &
       "ENTER THE PRINTER OPTION NUMBER OR [Q]:")))])) and &
       i <> "Q" do
 endwhile

This loop has no body and admittedly is probably less readable.  Yet, it does
not have hard-coded limits (like 1-15) since it relies on the existence
of vars previously set.

> SETVAR P "![PRINTER!I]"
and this also works:
   setvar p !"printer!i"  personal choice...

> SETVAR FILE '999'
> WHILE(NOT(FINFO('!FILE','EXISTS'))) DO
>   ECHO
>   INPUT NAME=FILE;PROMPT="ENTER THE FILE TO PRINT OR [Q]:"
>   IF ('!FILE' = 'Q' OR '!FILE' = 'q') THEN
>     RETURN
>   ENDIF
>   IF(NOT(FINFO('!FILE','EXISTS'))) THEN
>     ECHO SELECT A FULLY QUALIFIED FILE THAT EXISTS ;IE
> /ACCOUNT/GROUP/FILENAME
>   ENDIF
> ENDWHILE

This loop could be shortened to:
   while ups(setvar(file,input(&
         "Enter and existing file to print, or [Q]:"))) <> "Q" and &
         not finfo(file,'exists') do
   endwhile

> SETVAR F "![FILE]"
This can be simply:
  setvar f file    or you might be able to use the FILE var and not need F
...

--

ATOM RSS1 RSS2