7 Replies Latest reply on Nov 9, 2006 6:34 AM by wgb14

    BudAPI questions

    wgb14 Level 1
      Hi all,

      I wonder if there is any way to do the following by using Budapi

      i have a number of cast members that write on mousedown a specific line of text in a prefs file. Now, when my user exists the application i would like to renae the file to reflect the different users of my system. For example, if user one is using the system upon exit the prefs should remain as it is, if user 2 is using the system then upon exit the file prefs must become prefs1, if user 3 is using the system then, the file should become prefs2 and so on.

      This is the code that i have so far.

      on mousedown

      set x = 1
      TheNewINI = 1
      repeat while TheNewINI <> 0
      set TheNewINI = baFileExists(the applicationpath & "Prefs" & x & ".ini")
      if TheNewINI = 0 then
      set OK = baRenameFile("Prefs","Prefs" & x = x+1 & ".ini") -- rename the file

      Any idea what i am doing wrong? Please help me.....
        • 1. Re: BudAPI questions
          Lukewig Level 1
          Hi,

          The problem with your code is this line:

          aRenameFile("Prefs","Prefs" & x = x+1 & ".ini")

          It probably should be

          x = x + 1
          aRenameFile("Prefs","Prefs" & x & ".ini")

          Incidentally, an alternative approach would be to create an 'index' file. You use this index file to match a user to a pref file name. Something like this:

          • 2. Re: BudAPI questions
            wgb14 Level 1
            Hi

            Thanks for the answer... Your code seems more suitable than mine but i am not really insterested to keep any record of the number of users that will use my system. All i want is to rename the prefs file every time a new user clicks the exit button. Can we modify your code to do that?

            Many thanks
            • 3. Re: BudAPI questions
              wgb14 Level 1
              Well, I think i now understand better what you are trying to do in your code. But when i call this handler (on a mousedown event) i get the folloowing error.

              Script error: String expected
              prefFile = baReadIni("Users", userid, "error", the moviePath & "Users.ini")
              <VOID>

              Any idea why is that?

              Thanks
              • 4. Re: BudAPI questions
                Lukewig Level 1
                Hi,

                that means that 'userid' is not a string -- change it to

                baReadIni("Users", string(userid), "error", the moviePath & "Users.ini")

                Luke

                • 5. Re: BudAPI questions
                  wgb14 Level 1
                  All i am getting is a user ini file with the following information

                  [Settings]
                  PrefIdx=2
                  [Users]
                  =Pref2.ini

                  and no actual prefs2 or prefs3 files. I have tried this through both a projector and the director's authoring enviroment

                  Thanks
                  • 6. Re: BudAPI questions
                    wgb14 Level 1
                    I think i knwo where is the problem... the index file does not update itself and perhaps that's why the new files are not created. Any idea on how to solve this?

                    Thanks
                    • 7. Re: BudAPI questions
                      wgb14 Level 1
                      For anyone who is interested thats the answer to the above problem. It only runs in a projector

                      on saveAnINI
                      set budd = new (xtra "BudAPI")
                      set x = 1
                      TheNewINI = 1
                      repeat while TheNewINI <> 0
                      set TheNewINI = baFileExists(the moviepath & "Preferences\prefs" & x & ".ini")
                      if TheNewINI = 0 then
                      baCopyFile("J:\PhD Development work\My Director Works\Apps_with_Afrodity\Preferences\prefs.ini", "J:\PhD Development work\My Director Works\Apps_with_Afrodity\Preferences\" & "prefs" & x & ".ini", "Always")
                      else
                      x = x + 1
                      end if
                      end repeat
                      end