Announcement

Collapse
No announcement yet.

PB 3.5

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PB 3.5

    Here is my problem. I use the program with data that
    I download from a website and most times it will create the file
    correctly. But sometimes it creates the file and adds
    ****.txt (R) and says this is a read only file and I can't edit
    it. Also when I do to dosprint it doesn't recognize the file and
    won't print it. I have gone to windows explore and checked the
    properties of the file and it is archived. To create the file I
    am using the statement open "*****.txt for output as #1. I don't
    have clue as to where to look for this problem


    ------------------
    Jack Jasperson
    Jack Jasperson

  • #2
    I don't know the source of your problem, but you could programatically check the file to see if it is read-only, then change it before attempting to open it.

    I can't find any 'native' PB functions to do this but the DIRUNIT.BAS file shipped with 3.5 includes a function (DtaAttrib) to read the attribute. (( a file is in the DTA when it has been returned by the DIR$ function) .

    I don't see any function in the unit source file to set the attribute but either someone will suggest code or if worst comes to worse you can SHELL the attrib command-line utility to do so.

    MCM

    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      The PB DOS 3.5 ATTRIB function will return the attributes of the file
      and the ATTRIB statement sets the attributes of the file.

      Sincerely,
      Steve Rossell
      PowerBASIC Staff
      Sincerely,

      Steve Rossell
      PowerBASIC Staff

      Comment


      • #4
        Damn. The things you forget when you haven't used your PB/DOS compiler since 1997!



        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          I know what you mean, I thought it had these routines built in, but had to check the manual to be certain.

          Steve


          ------------------
          Sincerely,

          Steve Rossell
          PowerBASIC Staff

          Comment


          • #6
            I DID check the help file, and still missed them!

            (But I looked under "G" and "S" for 'GETATTR' and 'SETATTR.' I never looked under "A" and I don't think there is a "search by word" in PB/DOS help.)

            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              I have tried the above suggestions without help. But here is what
              I have discovered. The program does create the file because I
              shell to the dos editor and it displays my data. Again it has
              a file name of *****.txt (c) instead of *****.txt I can copy that
              data and save it under another name and exit the program and
              dosprint will print it. I then have went back to dos editor and
              searched for the orignal file and it isn't there. Then I have
              gone to explore and use find file or folder and searched for
              *****.txt and it does find only one file with zero data, but
              it doesn't find a file ****.txt (c). It is as if when I exited
              the dos editor that file just disappeared. :confused :mad

              ------------------
              Jack Jasperson
              Jack Jasperson

              Comment


              • #8
                What program/code is saving the file? The asterisk isn't a legal
                character for file names as far as I know.

                ------------------
                --
                C'ya
                Don
                don at DASoftVSS dot com
                http://www.DASoftVSS.com
                I program better than
                those who program faster
                and faster than those who program better.
                C'ya
                Don

                http://www.ImagesBy.me

                Comment


                • #9
                  Originally posted by Don Schullian:
                  What program/code is saving the file? The asterisk isn't a legal
                  character for file names as far as I know.

                  The * was used to represent any letter. I have tried jack.txt
                  and many other names for this file all with the same result.
                  Also I just reload pb3.5 in case something had been changed and
                  no improvement. Also I have renamed the file that I am input to
                  one that prints out correctly and this was no help


                  ------------------
                  Jack Jasperson
                  Jack Jasperson

                  Comment


                  • #10
                    Is the file open in this editor when you run your program?

                    Some editors change the attribute of a file to read-only when they have it open for editing.

                    And some editors open it for exclusive use, meaning no other program can do anything with it.


                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      As Michael Mattias would say post the that is not working so we can
                      see what you are doing.
                      KS

                      ------------------

                      Comment


                      • #12
                        Originally posted by Michael Mattias:
                        Is the file open in this editor when you run your program?

                        Some editors change the attribute of a file to read-only when they have it open for editing.

                        And some editors open it for exclusive use, meaning no other program can do anything with it.

                        No I create the file with the program and then shell to the dos
                        editor

                        ------------------
                        Jack Jasperson
                        Jack Jasperson

                        Comment


                        • #13
                          I don't see a CLOSE statement in your program code. That would explain the problem.


                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Originally posted by Michael Mattias:
                            I don't see a CLOSE statement in your program code. That would explain the problem.

                            Yes I have a close statement or else when
                            I repeat program with new data I would get a file already open
                            error


                            ------------------
                            Jack Jasperson
                            Jack Jasperson

                            Comment


                            • #15
                              Originally posted by Michael Mattias:
                              I don't see a CLOSE statement in your program code. That would explain the problem.

                              I had a close statement,but it was after the shell statement.
                              So I put the close statement before the shell statement and that
                              fixed the problem
                              Thanks Mike

                              ------------------
                              Jack Jasperson
                              Jack Jasperson

                              Comment


                              • #16
                                No it wouldn't. If the program terminates, if will force any open
                                files to be closed automatically, so when you run the program again,
                                no problem. But if you did not close the file after writing the
                                data to it, then try to access it with another program, you will
                                get an error, unless the file was designated to share access.

                                Again, unless you post sample code to show the problem, we can only
                                guess at what you are doing.

                                As stated, you cannot use either "*" or "?" in filenames, as they
                                represent wild cards. I take it from your post later that you are
                                trying different names, and that was what you were trying to
                                demonstrate. But you see how misleading it is when you do not show
                                the real code involved. You make it necessary for us to try and
                                second guess you in these matters.

                                ------------------
                                Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                                Comment

                                Working...
                                X