Qbasicnews.com
February 23, 2020, 08:54:18 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: If I could bother you guys once again...  (Read 8905 times)
joey7643
Member
*
Posts: 59


« on: February 13, 2003, 07:28:47 PM »

...for two issues:

(I appreciate all of the help you guys have given me!)

1) When displaying the contents of a directory in QB (C:\Program Files\, for example) where the number of files exceeds the number QB can display on screen, how would you display like 20 files, then print a message saying "Press <enter> to see the next 20 files..."? I am thinking something along the lines of a FOR...NEXT loop, but to no avail, I cannot think up a solution.

2) When I have dimmed a variable (such as DIM Variable1 AS STRING *100), and when I enter characters that are less than 100, the variable returns a REDO? error. I would like it so that you could enter up to and including 100 characters in that one variable without receiving an error message.

I have tried both of these problems on my own; I cannot seem to come to a single solution for any one of them.

Thanks for any help you could possibly give me.
Logged
NovaProgramming
Been there, done that
*****
Posts: 1025



« Reply #1 on: February 13, 2003, 07:43:14 PM »

Yeah, it's possible, hmm.  I think that you should wait till na_th_an gets on cause he's the one who knows about stuff like that more.  However, i'm sure there's a way.  i thinks it might have something to do with saving the 'dir' command to a .txt file and then reading that bit by bit, if you know what I mean.  anyway, na_th_an will talk to you cause he's awesome.
Logged

ovaProgramming.

One night I had a dream where I was breaking balls.  The next morning, BALLSBREAKER was born.

Quote from: "Haye, Phillip J."
 Excellent.  Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
joey7643
Member
*
Posts: 59


« Reply #2 on: February 13, 2003, 11:03:38 PM »

Yeah, I figured he might.  Cheesy
Logged
Dav
Administrator
Ancient Guru
*****
Posts: 709



WWW
« Reply #3 on: February 13, 2003, 11:30:14 PM »

Well, I don't know how you're doing the file listing, so my help may not be any help at all to you - but I'll try...

If you're using the FILES statement, FILES "filespecs", then no, I don't think you can pause the output like you asked.  And if you are using FILES at all be sure you also use some sort of error trapping, because if you do a FILES on a file spec that doesn't exist, then it will produce an error 53 and your program will halt right there.

You could maybe use the DOS command DIR, called by QB's SHELL statement and specify the /p parameter that pauses the output that way(like DIR *.* /p), or perhaps even redirect the output to a file and read the files that way (DIR *.* > files.txt).  Some people around here have written some good examples of using DIR that way and I'm sure would be happy to give it to you.

- Dav
Logged

na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #4 on: February 14, 2003, 09:02:48 AM »

To stop and wait for a keypress each 20 lines just add a counter of lines:

Code:
t$="C:\WINDOWS"
SHELL "dir "+t$+" /b >list.txt"
counter% = 0
CLS
OPEN "list.txt" FOR INPUT AS #1
WHILE NOT EOF(1)
   LINE INPUT #1,line$
   PRINT line$
   counter%=counter%+1
   IF counter%=21 THEN
      counter%=0
      PRINT "Any key ... ": SLEEP: k$=INKEY$
      CLS
   END IF
WEND
CLOSE 1
PRINT "EOF"
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
red_Marvin
Na_th_an
*****
Posts: 1509



WWW
« Reply #5 on: February 14, 2003, 11:04:11 AM »

Code:

SHELL "dir/p"
Logged

/post]
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #6 on: February 14, 2003, 12:17:13 PM »

variable.  Are you saying something like the following doesn't work?

DIM V AS STRING*100
LINE INPUT V
PRINT V
END

(I input "HELLO" at the prompt for V and everything worked just fine.)
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Hexadecimal Disaster
Been there, done that
*****
Posts: 1123



« Reply #7 on: February 14, 2003, 05:20:29 PM »

Someone forgot to include the puppy-eyes tag on their post, eh Nova?

Mr. wildcard has this pretty interesting code floating around here to avoid the use of SHELL for directory listing, the funny thing is that it seems that he forgot it... WHY you didn't mention it?

Code:
'DIR.BAS by Dave Cleary
'
'One of the most useful additions to BASIC 7 PDS is the DIR$ function.
'This function allows you to read a directory of filenames. It also
'allows you to check the existence of a file by doing the following:
'
'  IF LEN(DIR$("COMMAND.COM")) THEN
'     PRINT "File Found"
'  ELSE
'     PRINT "File not found"
'  END IF
'
'Now QuickBASIC 4.X users can have this useful function for their
'programs.
'
'Calling DIR$ with a FileSpec$ returns the the name of the FIRST
'matching file name. Subsequent calls with a null FileSpec$ return the
'NEXT matching file name. If a null string is returned, then no more
'matching files were found. FileSpec$ can contain both a drive and a
'path plus DOS wildcards. Special care should be taken when using
'this on floppy drives because there is no check to see if the drive
'is ready.

DEFINT A-Z

DECLARE FUNCTION DIR$ (FileSpec$)

'$INCLUDE: 'QB.BI'

'-----  Some constants that DIR$ uses
CONST DOS = &H21
CONST SetDTA = &H1A00, FindFirst = &H4E00, FindNext = &H4F00

'--------------------------------------------------------------------
'This shows how to call DIR$ to find all matching files

CLS
FileSpec$ = "C:\QB\*.*"
Found$ = DIR$(FileSpec$)
DO WHILE LEN(Found$)
   PRINT Found$
   Found$ = DIR$("")
LOOP

'--------------------------------------------------------------------

FUNCTION DIR$ (FileSpec$) STATIC

   DIM DTA AS STRING * 44, Regs AS RegTypeX
   Null$ = CHR$(0)

'-----  Set up our own DTA so we don't destroy COMMAND$
   Regs.AX = SetDTA                    'Set DTA function
   Regs.DX = VARPTR(DTA)               'DS:DX points to our DTA
   Regs.DS = -1                        'Use current value for DS
   InterruptX DOS, Regs, Regs          'Do the interrupt

'-----  Check to see if this is First or Next
   IF LEN(FileSpec$) THEN              'FileSpec$ isn't null, so
   'FindFirst
FileSpecZ$ = FileSpec$ + Null$   'Make FileSpec$ into an ASCIIZ
   'string
Regs.AX = FindFirst              'Perform a FindFirst
Regs.CX = 0                      'Only look for normal files
Regs.DX = SADD(FileSpecZ$)       'DS:DX points to ASCIIZ file
Regs.DS = -1                     'Use current DS
   ELSE                                'We have a null FileSpec$,
Regs.AX = FindNext               'so FindNext
   END IF

   InterruptX DOS, Regs, Regs          'Do the interrupt

'-----  Return file name or null
   IF Regs.Flags AND 1 THEN            'No files found
DIR$ = ""                        'Return null string
   ELSE
Null = INSTR(31, DTA, Null$)     'Get the filename found
DIR$ = MID$(DTA, 31, Null - 30)  'It's an ASCIIZ string starting
   END IF                              'at offset 30 of the DTA

END FUNCTION


Adapt the previous code by Mr. Na_th_an and you'll get something beautiful... oh, talking about Na_th_an, he's also writes poetry... (dejándose de leseras, ¿quién mierda escribió esto? Merece un premio)

Quote
###########################################
* Desconocido, Probablemente    [el 15 de febrero de 2003 ]
###########################################

..the uno quién escribe esta poesía no es
..the uno que nombre aparece sobre
..the uno quién escribe esto piensa que
..the uno quién fijó que esto debe pensar primer
..the uno quién fija estos poemas consigue
..the corregido uno quién los postes como esto consiguen comprobó
..the uno ahora ha hablado




AOOOOOHHH!! *howls of heavy laughter*
Logged

img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #8 on: February 14, 2003, 05:34:40 PM »

JEJEJEJEJJEE --- Quita eso de ahí, hombre, que hay niños y se nos mosquean los jefes Wink

Eso lo escribimos entre unos cuantos una noche de mucha cerveza y mucha maría... ¿cómo carajo lo has encontrado?


AJAJAJAJAJAJAA
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Hexadecimal Disaster
Been there, done that
*****
Posts: 1123



« Reply #9 on: February 14, 2003, 05:42:16 PM »

No importa, porque aún los que piensan que saben leer español no deben tener ni la más puta idea de la terminología utilizada...

So... kudos for you and your friends.
Logged

img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #10 on: February 14, 2003, 06:25:22 PM »

He he - Thanks man.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #11 on: February 14, 2003, 07:30:37 PM »

.
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Hexadecimal Disaster
Been there, done that
*****
Posts: 1123



« Reply #12 on: February 14, 2003, 08:38:10 PM »

Kazhdy drochit kak on khochet. Often poetry loses intensity when translated, so...  :roll:
Logged

img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Piptol
Ancient QBer
****
Posts: 422



WWW
« Reply #13 on: February 15, 2003, 12:01:04 AM »

Quote from: "Hexadecimal Disaster"
No importa, porque aún los que piensan que saben leer español no deben tener ni la más puta idea de la terminología utilizada...

So... kudos for you and your friends.


Well, some people understand more than you think.. and if you'd written that in English you'd most likely have got banned from the forum...

..so does that make it right?  :-?
Logged

In a world without walls and doors, who needs Windows and Gates?
Hexadecimal Disaster
Been there, done that
*****
Posts: 1123



« Reply #14 on: February 15, 2003, 01:11:42 AM »

Maybe. Feel free to send me your translation via PM so I can tell you your score. And if I'd written that in English, the poem would not rhyme.  :roll:
Logged

img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!