Page 1 of 1 1
Topic Options
#49513 - 2000-04-12 04:31 PM less than, greater than do not work. why?
Anonymous
Unregistered


What follows is a script to list files to be printed. Using a shell I am able to create a list of files and the show them to the user that will make the final selection of which one to print.
The problem is that the command prompt screen has a constrain on how many lines can be presented. That's why I limited the lines to be shown to 15, no more.
The user must select from the available files by selecting the line number. Here is the other problem: in the line that's supposed to limit the selection between 1 and 15, I am able to type numbers greater than those and the script file continues to work when it should send the message to select only between 1 and 15.
Any ideas what's going on? How to solve it?
Thanks.

;CODE BEGINS
BREAK ON
COLOR W+/B
CLS
$L = 1
$COUNT = 0

SHELL "%COMSPEC% /e:1024 /c DIR D:\spfiles\*.prn /on /b > d:\spfiles\list.txt"
SLEEP 2

IF Open(3, "D:\spfiles\list.txt",2) = 0
$x = ReadLine(3)
WHILE @ERROR = 0 AND $COUNT < 15
$COUNT=$COUNT+1
at ( 5+$count,0)? "File " $L " is: " + $X + " "
$X = ReadLine(3)
$L = $L + 1
LOOP
CLOSE (3)
ELSE
BEEP
? "File not opened, error code: [" + @ERROR + "]"
ENDIF

:FILENAME
BOX ( 0,9,5,68,SINGLE)
AT ( 2,12) "Select Line Number of File To Print"
AT ( 3,12) "Line Number is: "
GETS $LineNumber
IF $LineNumber = ""
MESSAGEBOX ("You MUST Type The Line Number of the File To Print.","File Name",64,5)
@ERROR = 0
ENDIF
IF $LineNumber =>1 or $LineNumber =<15
ELSE
MESSAGEBOX ("Please Select Line Number Between 1 and 15","File Name",64,5)
GOTO FILENAME
ENDIF

Open(4, "D:\spfiles\list.txt",2)
DO
$FileName = ReadLine(4)
$READ=$READ+1
UNTIL $READ = $LineNumber
CLOSE (4)
MESSAGEBOX ("D:\spfiles\$FileName will be printed on $Dest","File Name",64,5)
SLEEP 2
;CODE ENDS

Top
#49514 - 2000-04-12 07:16 PM Re: less than, greater than do not work. why?
PaulMoxey Offline
Getting the hang of it

Registered: 1999-07-22
Posts: 90
Loc: Villawood, NSW, Australia
A snippet from your code:

quote:

GETS $LineNumber
IF $LineNumber = ""
MESSAGEBOX ("You MUST Type The Line Number of the File To Print.","File Name",64,5)
@ERROR = 0
ENDIF
IF $LineNumber =>1 or $LineNumber =<15

try:
if val($LineNumber) =>1 or val($LineNumber) =< 15

at the moment, the mathematical great/less/equals sees $lineNumber purely as a "text" value as opposed to a numerical value. Due to it not being a numerical value at all, it seems to just ignore if statement and move on....

Hope this does the trick....

------------------
Paul Moxey
POS & Senior Network Administrator
Taubmans Pty Ltd
Paul_Moxey@taubmans.com.au

_________________________
Paul Moxey POS & Senior Network Administrator BarloworldCoatings (AUST) Pty Ltd

Top
#49515 - 2000-04-13 10:19 AM Re: less than, greater than do not work. why?
Anonymous
Unregistered


or you can use this one ...


code:

cls break on dim $inboxmsg[10]


SHELL "%COMSPEC% /e:1024 /c DIR D:\spfiles\*.prn /on /b > d:\spfiles\list.txt"


$input_file = d:\spfiles\list.txt"
$custom_msg_1 = "write your custom message here. Can"
$custom_msg_2 = "be anything you like. This menu is "
$custom_msg_3 = "created from the file 'my_datatxt' "
$custom_msg_4 = "and is only a demonstration."
$custom_msg_5 = "George Bouras, netcom@@matrix.kapatel.gr"
gosub menu_box

Open(4,$final_data,2)
DO
$FileName = ReadLine(4)
$READ=$READ+1
UNTIL $READ = $LineNumber
CLOSE (4)
MESSAGEBOX ("D:\spfiles\$FileName will be printed on $Dest","File Name",64,5)
SLEEP 2


; ********************************************************************
; ********************************************************************
; ** **
; ** Here is the Repository place for my functions and Sub Routines **
; ** **
; ********************************************************************
; ********************************************************************

goto "end"

; ******************************************************
; ******************************************************
;
; Here is a subroutine to create a Selection Menu. The
: contents of the menu are taken from an input file.
; Before use this subroutine you must have indicate the
; variable $input_file and if you want a custom message
; appearing to the menu window , indicate the variables
; $custom_msg_1, $custom_msg_2, $custom_msg_3,
; $custom_msg_4, and $custom_msg_5
; Your Selection is attached to the variable
; $final_data
;
; George Bouras
; netcom@matrix.kapatel.gr
;
; ******************************************************
; ******************************************************


:menu_box setascii(on) cls break on


if open(1,$input_file,2) <>0 goto "input_file_no" endif
do
$max_lines=$max_lines+1
readline(1)
cls
until @error=-1
close(1)
dim $the_data[$max_lines+1]
goto "input_file_ok"

:input_file_no
color r+/n
cls
box(9, 16, 13,61,double)
color c+/n at(11, 19) "Fail to open Input File " $input_file
at(11, 79)
get $b_sub
goto "exit_menu_box"


:input_file_ok
$n_sub=0
open(1,$input_file,2)
do
$n_sub=$n_sub+1
$the_data[$n_sub]=readline(1)
until @error=-1
close(1) cls

;---------------- Prepare the shifting effect -------------------

$data_sub=1 $line_sub=1
$delbox=" "
color c+/b box(0,0,24,35,double)

box(0, 37,16,79,double)
box(17,37,24,79,double) color w+/b

at (19,40) "Use the Up (" chr(24) ") or Down (" chr(25) ") keys to"
at (20,40) "Navigate the menu, and space or Enter"
at (21,40) "to choose the line you want."
at (3 ,40) $custom_msg_1
at (5 ,40) $custom_msg_2
at (7 ,40) $custom_msg_3
at (9 ,40) $custom_msg_4
at (11,40) $custom_msg_5

if $max_lines=2 $max_lines=3 $z_sub=1 endif
goto "select"
:start
get $b_sub
:select
select

;----------------- going up inside the box -------------------

case $b_sub=chr(72) and $line_sub > 0

$line_sub=$data_sub-$k
$data_sub = $data_sub-1
$line_sub = $line_sub-1
color b/b at($line_sub+4 ,1) $delbox ; delete the old box

$n_sub=$line_sub+4
$m=1
do ; write previous lines
color c+/b at($n_sub ,2) $the_data[$data_sub+1+$m]
$m=$m+1
$n_sub=$n_sub+1
until $n_sub=24 or $n_sub=$max_lines+2

color y+/b box ($line_sub+1, 1, $line_sub+3,34,double) ; create new box
color y+/b at ($line_sub+2, 2) $the_data[$data_sub+1] at($line_sub+2,79) ; write new data
$final_data=$the_data[$data_sub+1]

;----------------- going down inside the box -----------------

case $b_sub=chr(80) and $line_sub<20

if $line_sub > $max_lines - 3 or $z_sub = 1 goto "do_nothing" endif

$data_sub=$data_sub+1
$line_sub=$line_sub+1
color b/b at($line_sub,1) $delbox ; delete the old box

$q_sub=1
do ; write previous lines
color c+/b at($q_sub ,2) $the_data[$q_sub+$k]
$q_sub=$q_sub+1
until $q_sub=$line_sub+2

color y+/b box ($line_sub+1, 1, $line_sub+3,34,double) ; create new box
color y+/b at ($line_sub+2, 2) $the_data[$data_sub+1] at($line_sub+2,79) ; write new data
$final_data=$the_data[$data_sub+1]
:do_nothing

;----------------- going up over the box ---------------------

case $b_sub=chr(72) and $line_sub = 0 and $data_sub > 0

$k=$k-1
$z_sub=4
do
color b/b at($z_sub,1) $delbox ; delete previous lines
color c+/b at($z_sub,2) $the_data[$data_sub+$z_sub-3] ; write previous lines
$z_sub=$z_sub+1
until $z_sub=24

color y+/b box (1, 1, 3,34,double) ; create new box
color c+/b at(2 ,2) $the_data[$data_sub] at(2,79) ; write new data
$final_data=$the_data[$data_sub]
$data_sub = $data_sub-1

;----------------- going down below the box ------------------

case $b_sub=chr(80) and $data_sub<$max_lines-2

$data_sub=$data_sub+1
$k=$k+1
$n_sub=1

$n_sub=1
do
color b/b at($n_sub,1) $delbox ; delete previous lines
color c+/b at($n_sub,2) $the_data[$n_sub+$k] ; write previous lines
$n_sub=$n_sub+1
until $n_sub=21

color y+/b box (21, 1, 23,34,double) ; create new box
color c+/b at(22 ,2) $the_data[21+$k] at(22,79) ; write new data
$final_data=$the_data[21+$k]

;----------------- selection is made -------------------------

case $b_sub=chr(13) or $b_sub=chr(32)
goto "exit_menu_box"

endselect
goto "start"
setascii(off)
:exit_menu_box
color w/n cls
return


:end
color w/n



Top
#49516 - 2000-04-14 09:26 AM Re: less than, greater than do not work. why?
Anonymous
Unregistered


Thank you Paul for your snippet. I tried your suggestion but still didn't work but I do appreciate your response.
Thank you Novastar. I ran your code and is beautiful. It shows more than the 15 files limit I have with messages for the user and that is great. I am in the early stages of studying it thoroughly to understand it. I will let you know of the final product.
My deep appreciation for that.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 661 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.048 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org