6 Replies Latest reply: May 15, 2014 10:09 AM by acs_Manohara _ RSS

    Passing Run time parameter through VBS

    acs_Manohara _

      Hi ,

         I am having a problem in passing a date as run time parameter  through vbscript. Please suggest me on this.

       

      Even though i am passing a run time parameter the monarch is again asking for the date to be filled.

       

      the script is as below.

      -


       

           Dim MonarchObj

           Dim openfile, openmod, t ,x ,y,z

                 

           Set MonarchObj = CreateObject("Monarch32")

            

           If MonarchObj.IsActive > 0 then

              MsgBox("welcome")

           End If

       

              openfile = MonarchObj.SetReportFile("D:\clients\GP\JAIacct\acccounts\datafiles_initial\2010\august\161 Selective Ledger.txt",False) 

       

             If openfile = True Then

               

               z=MonarchObj.SetRuntimeParameter(Date,y)                  

               msgBox(z)                               

            openmod = MonarchObj.SetModelFile("D:\Manohar data\D drive\Models\GP_jai_SL_156_gl.xmod")

            

                If openmod = True Then

                         msgbox(openmod)

                   MonarchObj.ExportTable ("D:\DATA_bpf_new.csv")

                  End If

             End If

       

           MonarchObj.CloseAllDocuments

           MonarchObj.Exit

       

      -


       

        • Passing Run time parameter through VBS
          Bill Watson

          I may be misreading your code - but I can't see you actually setting a value to your y parameter. You include it in your dim statements but then do not populate it. If it is empty I believe monarch will continue to ask for the parameter manually. Additionally if i recall your parameter field name should be shown as a string i.e

           

          y = "19/01/2011"

          z=MonarchObj.SetRuntimeParameter("Date",y)

            • Passing Run time parameter through VBS
              acs_Manohara _

              sorry i attached the wrong code.

              -


                   Dim MonarchObj

                   Dim openfile, openmod, t ,x ,y,z

               

              Select Case Month (Date-30)

                Case 1, 3, 5, 7, 8, 10, 12

                 SetDates = "31"

                Case 4, 6, 9, 11

                 SetDates = "30"

                Case 2

                 If (Year(Date) Mod 4) = 0 Then

                  SetDates = "29"

                 Else

                  SetDates = "28"

                 End If

               

               

              End Select

               

               

               

              y=Month(Date-30)&"/"&SetDates&"/"&Year(Date-30)

               

              Msgbox(y)

                    

                       

                   Set MonarchObj = CreateObject("Monarch32")

               

                   If MonarchObj.IsActive > 0 then

                      MsgBox("welcome")

                   End If

               

                      openfile = MonarchObj.SetReportFile("D:\clients\GP\JAIacct\acccounts\datafiles_initial\2010\august\161 Selective Ledger.txt",False) 

               

                     If openfile = True Then

                       

                       z=MonarchObj.SetRuntimeParameter(Date,y)                  

                       msgBox(z)                               

                    openmod = MonarchObj.SetModelFile("D:\Manohar data\D drive\Models\GP_jai_SL_156_gl.xmod")

                    

                        If openmod = True Then

                                 msgbox(openmod)

                                MonarchObj.SetRuntimeParameter Date,y

                           MonarchObj.ExportTable ("D:\DATA_bpf_new.csv")

                          End If

                     End If

               

               

                   MonarchObj.CloseAllDocuments

                   MonarchObj.Exit

               

              -


               

              Even though we pass it as separate parameter its still giving the popup for data. please let me know the solution for this.

                • Passing Run time parameter through VBS
                  Bill Watson

                  As i said above I think your parameter field name should be shown as a string i.e

                   

                  z=MonarchObj.SetRuntimeParameter("Date",y)

                   

                  as currently your code will be treating Date as an undefined variable, i.e looking for field named after a value within Date (which is undefined), rather than "Date" as a field name. make sense?

                   

                  Also you should only need to set the parameter once, unless you plan on changing the value of it and running a different output using the same model.

                   

                  Edit: Not directly related to your post but the following will provide a more accurate determination of leap years:

                  If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5.

                  If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4.

                  If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5.

                  The year is a leap year (it has 366 days).

                  The year is not a leap year (it has 365 days).

                  /LIST[code]

                   

                  Dim MonarchObj

                  Dim openfile, openmod, t ,x ,y,z

                  Dim yr, ly

                   

                  yr = year(Date()-30)

                  if (yr mod 400) = 0 or ((yr mod 4) = 0 and (yr mod 100) <> 0) then

                     ly = 1

                  else

                     ly = 0

                  end if

                   

                  Select Case Month (Date()-30)

                  case 2

                     if ly = 1 then

                        SetDates = "29"

                     else

                        SetDates = "28"

                     end if

                  case 4, 6, 9, 11

                     SetDates = "30"

                  case else

                     SetDates = "31"

                  end select

                   

                  /code

                    • Passing Run time parameter through VBS
                      mdyoung _

                      This reply isn't directly related to your issue, but it's more of a helpful tip when trying to find the month's ending day. This is a little function I wrote that you can put in your VBScript. This way, you don't have to worry so much with leap year. In your case, here's how to use it.

                       

                       

                      SetDates = Day(EndOfMonth(Date() - 30))

                       

                       

                      Function EndOfMonth(dt)

                          Dim dtTemp

                       

                          ' Change the passing date to the beginning of the month.

                          dtTemp = CDate(Month(dt) & "/1/" & Year(dt))

                       

                          ' Add a month to the temp date and subtract one day

                          EndOfMonth = DateAdd("d", -1, DateAdd("m", 1, dtTemp))

                      End Function

                       

                       

                      /CODE