Results 1 to 8 of 8

Thread: File Location

Threaded View

  1. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    29

    Re: File Location

    Sub SaveStrategy(Strategy_and_Tuning_Name$)

    The actual argument name for Strateg _and_Tuning_Name$, which I can check in Development mode, is
    "C:\ProgramData\PC-ControLAB 3.1\DecupFwd.stg"
    Code:
    Dim exists As Boolean
    Dim Attr_ReadOnly As Integer, n As Integer, i As Integer, np As Integer, j As Integer
    Dim errreturn As Integer, Result1 As Integer, imax As Integer
    Dim FileExists As Integer, fileflag As Integer, attr As Integer
    Dim ext$, try$, x$, Path$, Filenamstg$, msg$, Path_plus_Filename$
    Dim nl$
    nl$ = Chr$(10) + Chr$(13)
    Attr_ReadOnly = 1
    
    Filenamstg$ =Strategy_and_Tuning_Name$
    
    'Is this a good file name?
    fileflag = 0
    Call fileok(Filenamstg$, errreturn)
    If errreturn <> 0 Then Exit Sub
    
    ' If we got to here, it's a good files.
    ' Check file. If it exists, can we overwrite it?
    FileExists = (Dir(Filenamstg$) <> SEmpty$)
    If FileExists = -1 Then
        fileflag = 1
        attr = GetAttr(Filenamstg$)
    In Development mode, this last statement gives halts with Error Message #6, Overflow.
    In Runtime, it gives no error message and doesn't halt.
    Code:
        attr = attr And vbReadOnly
        If attr = vbReadOnly Then  'File property Read Only is NOT set.
    
            msg$ = "Process strategy file is Read Only."
            msg$ = msg$ + nl$ + "Select another file name and/or directory."
            MsgBox msg$, 48, "PC-ControLAB 3.1"
            On Error GoTo 0
            Exit Sub
        End If
    End If
    
    ' All files are clear.  Let's do it.
    Screen.MousePointer = 11
    Open Filenamstg$ For Output As #4
    Here's where I am trying to open the existing file, C:\ProgramData\PC-ControLAB 3.1\DecupFwd.stg.
    I used the word "apparently" because that is the argument that I passed. See below.
    Code:
    SaveStratRecheck:
    '
    Print #4, ControlStrategy
    Print #4, Path_plus_ModelName$
    '
    '   Tuning Options
    '
    Print #4, GainorPB      'Proportional Tuning. Gain or PB
    Print #4, MPRorRPM      'integral tuning Min/Rpt or Rpt/Min
    Print #4, IDTMS         'integral time units in mins or sec
    Print #4, Spareslot
    Print #4, Spareslot
    
    'Here is where I print these, and lot more parameters of this particular Control Strategy.  Then
    
    Close #4
    Screen.MousePointer = 0
    MsgBox "Strategy and tuning file " + Filenamstg$ + " successfully saved.", , "PC-ControLAB 3.1"
    WRONG! When I examine the file that I had hoped to save (actually, update), I find that neither the file date nor the data in the file has not been changed. Instead, if I do a Windows Explorer search, I find that there is a file

    C:\Users\MyName\AppData\Local\VirtualStore\ProgramData\PC-ControLAB 3.1\DecupFwd.stg

    that does have the correct file data and the file data that I intended to write to the other file.

    My question remains: Why, when I pass one valid argument, does the system ignore that argument and store the data in a location that I did not intend, nor specify? The problem may be in my computer configuration, but I don't believe it is within my code per se.
    Last edited by Hack; Jun 18th, 2013 at 08:05 AM. Reason: Added Code Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width