File / directory dialog box

My first ever post to this forum was in the beginning of February and it was to ask for information on Interupts. I didn't get any replies, which is probably just as well, but KDivad Leahcim did remind me of the SHELL command, which I'd forgotten about.

The reason I asked was because I'd had an idea about writing a file dialog box. Well, I finally got round to writing it, and if you're interested you can see the results at http://members.lycos.co.uk/brisray/qbasic/qfdlog.htm

Ray

Comments

  • Thanks Ray... I'll take a look at it. What was your original question? (never did get a chance to see it)


    : My first ever post to this forum was in the beginning of February and it was to ask for information on Interupts. I didn't get any replies, which is probably just as well, but KDivad Leahcim did remind me of the SHELL command, which I'd forgotten about.
    :
    : The reason I asked was because I'd had an idea about writing a file dialog box. Well, I finally got round to writing it, and if you're interested you can see the results at http://members.lycos.co.uk/brisray/qbasic/qfdlog.htm
    :
    : Ray
    :

  • Hi Alan,

    My original post was :-

    If there is anyone to who is willing to explain how to use interupts in QBasic 1.1 to me can they please email me.

    I'm particularly interested in mouse and file routines.

    I'm also interested to know if there is a way of getting file lists into a file or variable. FILES just puts the list onto the screen.

    ***********************************************************
    To tell the truth I'm not surprised I didn't get many replies. It's a huge subject and akin to "teach me programming". It's just something I have never really managed to get my head around.

    What I'm finding is that a lot of the QBasic programs I find that use interupts just don't work properly and produce some weird video effects. A situation I think will get worse as Microsoft moves Windows further away from the DOS environment.

    Ray

  • : Hi Alan,
    :
    : My original post was :-
    :
    : If there is anyone to who is willing to explain how to use interupts in QBasic 1.1 to me can they please email me.
    :
    : I'm particularly interested in mouse and file routines.
    :
    : I'm also interested to know if there is a way of getting file lists into a file or variable. FILES just puts the list onto the screen.
    :
    : ***********************************************************
    : To tell the truth I'm not surprised I didn't get many replies. It's a huge subject and akin to "teach me programming". It's just something I have never really managed to get my head around.
    :
    : What I'm finding is that a lot of the QBasic programs I find that use interupts just don't work properly and produce some weird video effects. A situation I think will get worse as Microsoft moves Windows further away from the DOS environment.
    :
    : Ray
    :
    :

    Very nice! Too bad all I can claim is reminding you of the Shell command.

    DOS 5-7 all look pretty much the same (I think...). QBasic does not affect the output in any way.

    One thing you can look at (you might already have, I didn't check) is the LFN (long file name). If the DOS session is running under Windows, the LFN is appended to the line. You could easily get it similar to your current method of stripping out info. You could then display it somewhere on your dialog. I'd also consider adding the file's size. I can't think that either would add much code.

    Another alternative is to create the dialog in VBDOS. I've done this before and it's fairly easy. I dim a variable and pass the VARSEG and VARPTR values to a VBDOS exe. It runs whatever code it is supposed to and POKEs the new value into that location. Upon returning, QB has the new info.

    Also, VBDOS can make .QLB files that you might be able to use in QB but I've never tried that.
  • Thanks KDivad,

    When I wrote that original post I knew there was a way of doing it, but for the life of me couldn't remember what it was.

    I use QBasic 1.1 on a Windows 2000 OS (basically NT).

    When I started writing the program I assumed that what I'd get when I typed DIR > temp.tmp at the command prompt would be the same as when I used SHELL "DIR > temp.tmp" in the program. This isn't what happens. DIR from the command prompt gives long file names, from the SHELL command it gives the old 8.3 format.

    Either QBasic 1.1 has a command processor built into it, or Win 2000 realises the call is coming from a 16 bit program and using a 16 bit version of Dir. Either way, no long file names, not using this method anyway. Getting the file lengths from the file is easy enough, but I want to use that for something else that's going on inside my head at the moment.

    Although I did a fair bit of testing a couple of people have said that the program is locking up when it tries to access an empty B: drive. The error checking I put into it works fine on my machine. I know from other machines I've used that QBasic 1.1 acts a little differently on the various Windows versions. Also, there are three common versions of QBasic in use, 1.1, 4.5 and 7.1, and that these behave a little differetly from eachother too. So I'll blame Microsoft for the program locking up rather than any coding that I did.

    Ray
  • : When I started writing the program I assumed that what I'd get when I typed DIR > temp.tmp at the command prompt would be the same as when I used SHELL "DIR > temp.tmp" in the program. This isn't what happens. DIR from the command prompt gives long file names, from the SHELL command it gives the old 8.3 format.
    :

    Interesting, I was unaware of that. It could be that 2K detects the difference and acts accordingly. I suspect it is likely that cmd.exe (a windows app) loads a DOS-based command interpreter (command.com) and has it load the program. This psuedo-command.com module may be windows-unaware.

    Here's an idea if, as I suspect, %compsec% is set to cmd and not command:

    SHELL ENVIRON$("COMSPEC") + " /c DIR > temp.tmp"

    Essentially, you'd be launching cmd (or command on previous versions of windows) and telling it to create the file.


    Anyway, great work on that code!
  • Thanks, that's exactly it.

    I've just checked the environment using SET. Compspec IS set to cmd.exe
    Now I also know how to find the users temporary directory. A bit more file reading and that'll be sorted too.

    It's nice to know all the old DOS stuff I learned on my once almost "state of the art" 8086, an Amstrad 1640 to be precise, is still useful.

    Ray
  • Ray,

    Looking at the other posts in this thread, I see you've been given some very sound information. As for the DIR command issue, there are still other means to obtain that information (INT21 = hint).

    As for using interrupts in QBasic, there are several excellent referneces (many of them are right here on this board). I'm curious about your comment on the weird video behaviour... what interrupt(s) were you calling?, describe the effect(s).

    Alan


    : Hi Alan,
    :
    : My original post was :-
    :
    : If there is anyone to who is willing to explain how to use interupts in QBasic 1.1 to me can they please email me.
    :
    : I'm particularly interested in mouse and file routines.
    :
    : I'm also interested to know if there is a way of getting file lists into a file or variable. FILES just puts the list onto the screen.
    :
    : ***********************************************************
    : To tell the truth I'm not surprised I didn't get many replies. It's a huge subject and akin to "teach me programming". It's just something I have never really managed to get my head around.
    :
    : What I'm finding is that a lot of the QBasic programs I find that use interupts just don't work properly and produce some weird video effects. A situation I think will get worse as Microsoft moves Windows further away from the DOS environment.
    :
    : Ray
    :
    :

  • Using QBasic fullscreen on my my machine (I use v1.1 and Windows 2000) will, more often than not, completely lock QBasic. The machine runs fine but QBasic will not respond at all, and I have to use task manager to close it down. This happens whether or not interupts are being used.

    Windows 2000 is supposed to have better memory protection mamnagement, which usually causes these problems, but seems worse than other versions of Windows I've tried (3.11, 95, 98 and ME).

    I've set the PIF for QBasic to use Protected Mode and to prevent QBasic from recognising Windows which worked well for other Win versions.

    Programs using interupts

    Some programs, especially those that feature the mouse, don't seem to register it properly. The symptoms vary with the program. On some where the mouse X,Y co-ords and button presses are displayed to the screen, the mouse pointer works fine, but the other items don't display properly. On others nothing works at all. On some programs the mouse cursor movement is too jerky and unpredictable to be of use. Other programs cause the mouse pointer to become a little white square. Usually, in these programs, the movement becomes very jerky and odd trails appear. Other times the mouse pointer simply leaves trails. Out of the dozen or so mouse programs I've tried not one works properly.

    Other programs that use interupts in any shape or form cause the screen to become very distorted and lock up. I'm sure you've seen the effect, it looks like as if the screen has been smeared from left to right.

    I'm not too worried about it, I've lived with DOS programs without a mouse long enough. It's just frustrating that I don't know enough about interupts and QBasic to write my own version and see what's going on. It is on my list of things to do, along with the other million or so other items that I either have to do or will do as soon as I find some time.

    Ray
  • : Thanks, that's exactly it.
    :
    : I've just checked the environment using SET. Compspec IS set to cmd.exe
    : Now I also know how to find the users temporary directory. A bit more file reading and that'll be sorted too.
    :
    : It's nice to know all the old DOS stuff I learned on my once almost "state of the art" 8086, an Amstrad 1640 to be precise, is still useful.
    :
    : Ray
    :

    Great! Glad I could help a bit more.

    Seems Microsoft still isn't quite ready to completely eliminate DOS...
  • I've just been playing with DOS and the PC environment.

    It doesn't seem to matter whether or not the comspec is set to command.com or cmd.exe

    I've set and reset them both from the command line and from inside QBasic using SHELL. DIR at the DOS prompt will produce the long filenames, from inside QBasic you always get the 8.3 format.

    I also tried using the /N and /X switches from inside QBasic, both came back with error messages saying that the switches were invalid. This leads me to suppose the DIR is being loaded from yet another command processor, one that I'll have a go at tracking down.

    Ray

    A quick DOS lesson, probably not for KDivad or Alan

    You can view the PC environment by using SET at the command prompt
    You can change an environment string from the command prompt by using
    SET=(the string you want to change)
    [No spaces either side of the ='s sign]
    eg to change the comspec line from ComSpec=c:winntsystem32cmd.com
    you can use

    set cpmspec=c:winntsystem32command.com

    I'd be careful changing too much else though, I expect weird things will happen if you change the wrong thing.

    Prompt was always a good one to play with.

    set Prompt=$d $t $g displays the date and time as the DOS prompt

    This will only be effective until the next time the computer is rebooted. The usual default for the prompt is Prompt=Sp$g
  • How annoying!!!!!... I just finished writing a rather long response which addressed a number of previously discussed issues in this thread... but when I went to post it, I was told I had to login... I already had logged in. Needless to say, upon return to the reply I had written... gone... little bits and bytes off floating in space, drowning in some bit-bucket somewhere. Rats.

    I'll rewrite the post and email it to you. :(
    Alan
    (why does PH do that?!?... it's not the 1st time either)

  • lol, I've had that problem too, perhaps one day all those bits will come back to haunt us all.

    I'm still playing around with this stupid program.

    SET returns a different set of results depending on whether it is run from the DOS prompt or from the SHELL command. This has got to be because Windows is running in protected mode.

    From SHELL the TEMP directory is reported as being TEMP=C:WINNTTEMP
    From DOS the TEMP directory is reported as being C:DOCUME~1BRISRAYLOCAL~1TEMP

    Resetting any of the variables from inside QBasic doesn't seem to work, Command.com to cmd.exe etc. Also, I've extracted the temp directory from the SHELL, and put it into a variable, so that Tempfile$ is now c:winnt emp emp.tmp

    This now renders the program useless as Windows seems to block the program from writing to the temporary file. Once again I suspect due to the protected mode.

    I think I've done as much as I can on this for now, I'll certainly be keeping what I've learned for future reference. It does bring up another interesting point though. Microsoft have said that they want to move away from DOS from Windows XP and future versions of it. I wonder what else isn't going to be available though the SHELL command?

    Ray

  • [b][red]This message was edited by the PrzemekG_ at 2002-3-8 5:37:3[/red][/b][hr]
    I can't make the dialog works. First there is the Microsoft famus Blue Error Screen with "Insert disk to B: drive" and then error 5.

    It can be becose I have a polish version ow windows and dos, my dir command output is:
    [code]

    Wolumin w stacji dysk˘w C: DOROTA CU
    Numer seryjny woluminu: 2B35-1A01
    Katalog C:przemekCOMPILS1

    .
      01-16-02 8:16p .
      ..
        01-16-02 8:16p ..
        BC7
          01-16-02 8:16p BC7
          COMPI001 ZIP 30,931 02-27-02 8:10p compi001.zip
          SLC004 ZIP 51,463 02-27-02 8:10p slc004.zip
          COMPI001
            02-27-02 8:10p compi001
            PHP
              03-04-02 11:47a PHP
              TASM
                01-18-02 12:21a Tasm
                MASM
                  02-08-02 1:32a MASM
                  MOONROCK
                    01-16-02 6:50p MoonRock
                    TUTORIAL
                      01-19-02 4:02p tutorial
                      TP7
                        01-21-02 5:37p TP7
                        SLC004
                          02-27-02 8:31p slc004
                          QB45
                            07-09-00 11:03p qb45
                            RAPIDQ
                              03-03-02 11:34p RapidQ
                              XB
                                10-21-01 6:53p XB
                                VB5~1 0EN
                                  11-01-01 11:05p VB 5.0 Ent
                                  VBDOS
                                    01-13-02 9:33a vbdos
                                    DIR TXT 0 03-08-02 1:34p dir.txt
                                    3 plik(˘w) 82,394 bajt˘w
                                    16 katalog(˘w) 43,888,640 bajt˘w wolnych
                                    [/code]


                                    All polish letters IE replace by &#???
  • The B: disk thing works with no problem on mine, (QBasic 1.1 on Windows 2000). I guess different OS's give different errors when running this. I guessed this would happen when I wrote the thing, but couldn't do much about it.

    Both of these is because of the Command.com / Cmd.exe thing that I've mentioned before. A work around for this, if you want to try it is

    Rewrite the lines near the top of the program:-

    ON ERROR GOTO DriveErr
    FOR Count = 65 TO 90
    ProgErr = 0
    Message$ = CHR$(Count) + ":"
    FILES Message$
    IF ProgErr = 0 THEN Drive$ = Drive$ + CHR$(Count)
    NEXT Count

    So that they become

    Drive$ = "A"
    ON ERROR GOTO DriveErr
    For Count = 67 TO 90
    ProgErr = 0
    Message$ = CHR$(Count) + ":"

    etc etc

    Not the best solution, as the drivelist is now preset with an A drive, then misses B altogether before carrying from C, but it's the best I can do off the top of my head.

    As to the dir listing itself, there shouldn't be any problems with that. So long as it's the result you get from within the SHELL command in QBasic. Although the lines are longer than mine, it will still work. What is happening with your version is that short filenames are on the left, which is where mine are, but yours is displaying the long file names on the right as well. As the program reads the whole line in and the file names are in the same place at the begining of the line, it will still work.

    You can easily check what is happening by writing a short program for yourself. All it needs is one line SHELL "Dir > C: emp.tmp"

    Close the program and open the file temp.tmp
    The layout should be exactly the same. If the file names and extensions are somewhere else I'll tell how to modify the program. It should be easy enough to do it your self if you want to give it a go. Replace the lines in GetCurrent

    Num = INSTR(FileInfo$, " ")
    Num = Num - 1
    FileName$(NumFiles) = LEFT$(FileInfo$, Num) + "."
    FileName$(NumFiles) = FileName$(NumFiles) + MID$(FileInfo$, 10, 3)

    with the position of the filenames as diplayed in temp.tmp

    It should end up looking something like this (but not exactly)

    Num = INSTR(fns, FileInfo$, " ")
    Num = Num - 1
    FileName$(NumFiles) = MID$(FileInfo$, fns, Num) + "."
    FileName$(NumFiles) = FileName$(NumFiles) + MID$(FileInfo$, fes, 3)

    where "fns" is the start of the file name position
    and "fes" is the start of the file extension position inside temp.tmp

    Do not use the long file names as the program is designed to use the short file names and I don't quite know what will happen, but I can guess they'll give some weird displays.

    I hope that this can at least get the program working for you.

    When I write the programs for my pages, I try to show general logic ideas, and some things that can be done with QBasic. Until I wrote FileDir I had no idea that different versions of Windows could stop a relatively simple program from working properly. I assumed that QBasic was QBasic no matter what version of Windows it was run on. My apologies to you and anyone who else has tried this program and found it hasn't worked.

    Ray


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories