none
Read/Write for Variables

    Question

  • Hi,

     

    I am using a Script Component and I have a Read/Write Variable varStatusCase (as assigned in the Custom Properties of my Script Component). I used this inside my script to get a specific value. However, when I ran it I get this error:

     

    The collection of variables locked for read and write access is not available outside of PostExecute.

     

    How do I repair this?

     

    Thanks,

     

    cherriesh

    Friday, August 03, 2007 8:26 AM

Answers

  • If you want to write on a variable you have to use the post execute method something like this

    Public Overrides Sub PostExecute()

     

    Me.Variables.varName = Something

     

    End Sub

     

    I dont know if there's another way to do it but this is the only one i've found. And it works.

    Friday, August 03, 2007 11:55 AM

All replies

  • If you want to write on a variable you have to use the post execute method something like this

    Public Overrides Sub PostExecute()

     

    Me.Variables.varName = Something

     

    End Sub

     

    I dont know if there's another way to do it but this is the only one i've found. And it works.

    Friday, August 03, 2007 11:55 AM
  • But just know that this doesn't execute for every row.

     

     

     

    Friday, August 03, 2007 12:09 PM
  • Friday, August 03, 2007 1:12 PM
  • hi,

     

    I tried doing what is in your link:

     

    Private NextKey As Int32 = 0

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

    Dim MaxKey As Integer = Me.Variables.varStatus

    NextKey = MaxKey + 1

    Row.oStatusCode = NextKey

    MyBase.PreExecute()

    End Sub

     

    Public Overrides Sub PreExecute()

    Me.VariableDispenser.LockForRead("User::varStatus")

    MyBase.PreExecute()

    End Sub

     

    Public Overrides Sub PostExecute()

    Me.ReadWriteVariables("varStatus").Value = NextKey

    MyBase.PostExecute()

    End Sub

     

    My variable "varStatus" is assigned in Script Component ReadWrite Variable.

     

    Am I missing anything? I'm still having the same error.

     

    cherriesh

    Sunday, August 05, 2007 1:35 AM
  • dear friend,

    copy my statment in my post... check the link... the solution is there.

    check the pre-execute method

    helped?

     

    Sunday, August 05, 2007 9:50 AM