Announcement

Collapse
No announcement yet.

Error 70: Permission Denied

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

  • Error 70: Permission Denied

    I have written a program to remove extranenous spaces in a space
    delimited data file. The file is huge, 13.89MEG, and I think I can
    cut the size down to a third of that (or more) just by removing
    extranenous spaces.

    The code compiles fine, but when I test it to read the first line,
    I get an Error 70: Permission denied error.

    I thought Error 70 in Powerbasic occurred when [u]writing[/b] to a file,
    that you do not have permission to do so, not simply reading the
    file. I checked the attributes and it is set to Read Only. Is that
    a problem?

    Thank you.

    Robert

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

  • #2
    You sure the error didn't occur on the OPEN, rather than the READ? (Code showing how you tested the error conveniently not shown).

    You'd get an error 70 if your open mode (also conveniently not shown) were inconsistent with the read-only attribute.

    You could also get a spurious error 70 if some prior error in your program (you guessed it) were not handled at that time.


    MCM


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

    Comment


    • #3
      No I can't say with 100% certainty that it occured [b]during[/b the read.

      However, I can say with 100% certainty that in the debugger, I get
      past the OPEN statement. It <U>acts</U> as it the error occurs at
      the "while not EOF(1)" statement, but the debugger flies through
      it I can't tell if that is the culprit or the next statement.

      I could post the code, and don't mind. I remember PowerBasic
      scolding someone for doing that, though, since it contained
      copyrighted code. Hence, I have a little fear of doing so. It is
      just a short program, with more to be added later. The "hurdle"
      is being able to read the file at all. I don't think I used
      anything copyrighted. I will take your advice- should I post the
      code and if I do, is it safe?

      Thank you.

      Robert

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

      Comment


      • #4
        If the code is 100% yours and does not contain any 3rd party
        routine(s), it's perfectly safe to post your code.


        ------------------
        There are no atheists in a fox hole or the morning of a math test.
        If my flag offends you, I'll help you pack.

        Comment


        • #5
          Maybe turn off your anti-virus program (especially if it's Norton) and try again. I had something very similar to this happen. Although I got no error, I got no results. The read and write operations were just skipped until I turned off my antivirus. It drove me nuts for days.

          -Michael.

          Comment


          • #6
            It is McAfee, not Norton. However, I have tried four times to
            post the code here. I type "
            Code:
            " and started typing. (It is
            not that long.)  Typed "
            " and I thought it went to the
            forum. Was it deleted?


            Thank you, and I will try turning off the McAfee.

            Robert

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

            Comment


            • #7
              I wonder if you are seeing a manifestation of the "error 70" that I describe in the thread about the "original" PB/DOS below.

              ------------------
              PB/DOS 3.5 on Fedora Linux

              Comment


              • #8
                Robert--

                If anyone is to help you, they must be able to see your code. Without it, there is only wild speculation.

                You've posted 3 messages here quite successfully. Try a fourth, in precisely the same fashion, and type in the appropriate code.

                Then folks can see what you have and suggest the cause and cure.

                Thanks!

                Bob Zale
                PowerBASIC Inc.


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

                Comment


                • #9
                  I understand that the need to see the code. Ok, I will try it
                  without formatting and see if that goes though. Thanks for
                  bearing with me.
                  ----------------
                  FilenameIN$="C:\PDB\NPBD.DAT"
                  FilenameOUT$="C:\PDB\NPDBO.DAT"

                  open FilenameIN$ for input as #1
                  Open filenameOUT$ for output as #2

                  while not eof(1)
                  Flagg=1
                  while Flagg=1 :'{stops here}
                  flagg=0 :'set flag :'{stops here}
                  Input #1, CompleteLine$ :'{stops here}
                  LineLen=len(CompleteLine$)
                  NewLine$=""
                  for I = 1 to LineLen
                  TearOffTwo$=mid$(CompleteLine$,i,2)
                  if TearOffTwo$ <> " " then
                  NewLine$=NewLine$+TearOffTwo$
                  else
                  i=i+1 :'dont write the spaces, don't want the xtra spaces.
                  Flagg=1 :' set the flag
                  endif
                  CompleteLine$=NewLine$
                  loop

                  Print #2, CompleteLine$ :'write the line back, minus xtra spaces.
                  Looop :'get next line until done

                  close all
                  cls
                  print "Done, Hombre."
                  end

                  I.e., if I line looks like this:
                  "Facing West ","Anderson, Janice ","1880-7-12 ","1940---- "
                  I want to change that to:
                  "Facing West","Anderson, Janice","1880-7-12","1940----" and so on.....
                  OBvisously +some+ spaces are necessary, but most are not.


                  I put in braces {,} where the debugger stops. Not the same
                  place every time. Here's hoping it goes thru this time. I hope
                  I re-typed it correctly.
                  Thank you so much guys.

                  Robert

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

                  Comment


                  • #10
                    Robert,

                    One error that I noticed is that you spelled the external loop
                    incorrectly within your code Looop. Also, try to avoid using
                    multiple statements on one line. This will make your program
                    easier to read as well as debug. You are missing a space in End If.
                    I do not see a Next statement that corresponds with your For statement.
                    You should try indenting, it too will make your code easier to read.

                    Allen


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

                    Comment


                    • #11
                      I knew I was going to leave something out! I sure didn't
                      mean to skip the End If.

                      The first three times when I typed this, I +did+ indent. So this
                      time I thought I'd do better if I didn't indent.

                      The mis-spelling of Looop was my fault in re-typing. It is Loop
                      in the program.

                      Any thoughts as to what could cause the Error 70? I am totally
                      out of ideas.

                      Robert

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

                      Comment


                      • #12
                        Before you begin typing or pasting your code type left sqbracket code right sqbracket ie
                        "
                        Code:
                          ", do this on a line by itself. 
                        This will tell the software of the board to keep your formatting.
                        When you are done with your code type in left sqbracket /code right sqbracket ie "
                        "
                        This will tell the board you are done with the formated code.
                        "
                        Code:
                        "  The double quote are not used
                        code here
                        "
                        "
                        To see the code tags click the edit message icon.
                        KS

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


                        [This message has been edited by keith shelton (edited April 04, 2005).]

                        Comment


                        • #13
                          Code:
                          open FilenameIN$ for input as #1
                          IF ERR THEN
                             
                          Open filenameOUT$ for output as #2
                          IF ERR THEN
                          ...
                          You'd absolutely get an error on LINE INPUT if the open failed.

                          This is exactly what I meant when I suggested the failure to handle an error <U>when it happens</U> can cause a spurious error later.




                          [This message has been edited by Michael Mattias (edited April 04, 2005).]
                          Michael Mattias
                          Tal Systems Inc. (retired)
                          Racine WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            This is what the left square stuff looks like as you type it:


                            Code:
                               
                            
                            Code:
                             
                                  FUNCTION Something that ends up like I want it() as long
                                       DIM Foo, Gym, Gold, Dirt as long
                                         Dirt = 0
                                         Gold = 455
                                         For foo = Dirt to Gold
                                             Gym = foo * Gold
                                         Next
                                   End Function
                            Using the code directive will keep your formatting.
                            Hint: Paste the program code in following the bracketted code keyword, followed by the bracketted /code word.

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




                            [This message has been edited by Barry Erick (edited April 04, 2005).]
                            Barry

                            Comment


                            • #15
                              Robert,

                              I still do not see a Next statement in the code.

                              Allen


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

                              Comment


                              • #16
                                Robert,

                                Is this running under DOS, or as a DOS box under Windows, and what version?

                                You could have a secure file where under Windows, trying to acces a
                                file like WIN386.SWP would yield a permission denied. Under pure DOS However,
                                the file is accessible.

                                Tim www.omnixray.com


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

                                Comment


                                • #17
                                  I am confounded as to why you don't get a compile-time error. I don't have the DOS compiler installed to check, but is this legal syntax?

                                  Code:
                                  WHILE NOT EOF(1)
                                     ...
                                     WHILE Flagg = 1
                                     ..
                                     ..
                                     LOOP
                                     ...
                                  LOOP
                                  You are closing WHILE with "LOOP". It Should be WHILE..WEND. Also, maybe a typo but you did forget your NEXT statement in the FOR block as Allen pointed out. And as Michael Mattias said, you should definitely test for errors with your OPEN statements. Also a good Idea to use FREEFILE instead of hard coding the file handles.

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




                                  [This message has been edited by Michael K. Dealey (edited April 04, 2005).]

                                  Comment


                                  • #18
                                    Michael-

                                    While.....
                                    statements
                                    Wend

                                    IS the correct format. Now that you mention it, I am a little
                                    surprised I did not get a compile error.

                                    I typed While ... Loop because my first Basic course that was
                                    valid. Make that mistatke a lot in PB.

                                    I will try Michael's suggestion.

                                    Robert

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

                                    Comment


                                    • #19
                                      I believe LOOP and WEND are interchangeable.....

                                      ------------------
                                      Tom Hanlin, PowerBASIC Staff
                                      Opinions expressed may not be those of my employer or myself

                                      Comment


                                      • #20
                                        I believe LOOP and WEND are interchangeable
                                        They are for a factus absolutius.

                                        This topic was covered before with (I think) MM. This little
                                        "feature" caused me a lot of grief in a program I was writing
                                        several years ago.

                                        I had a While/Wend nested inside a Do/Loop and wanted to exit
                                        the Loop while inside the While. It only exited the Wend and
                                        I couldn't figure it out for a hoop of time.

                                        I just re-read my 3rd paragraph and I hope it makes sense.

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


                                        [This message has been edited by Mel Bishop (edited April 04, 2005).]
                                        There are no atheists in a fox hole or the morning of a math test.
                                        If my flag offends you, I'll help you pack.

                                        Comment

                                        Working...
                                        X