Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline TheWizEd  
#1 Posted : 18 August 2013 17:41:53(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
I was resurrecting my WizFunctions for use with the newer version of SMath Studio and code that used to work now doesn't.

The problem seems to be with Store.AddDefinition. Possible causes are Definition.IsFunction has no object reference but is ReadOnly so no way to set it. Or AddDefinition variables() needs to be initialized and I don't have a clue to what.

Any suggestions would be appreciated. Thanks.



[Moderator] Moved.

Edited by moderator 18 August 2013 18:11:05(UTC)  | Reason: Not specified

Ed

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Davide Carpi  
#2 Posted : 18 August 2013 17:57:06(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1331 time(s) in 876 post(s)
Hi TheWizEd Good

Here and here you can see some updated store.AddDefinition examples Good


Best regards,

Davide
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline TheWizEd  
#3 Posted : 19 August 2013 01:02:32(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
w3b5urf3r

I looked at your examples and at least now it doesn't crash but it's not storing the variable. What am i doing wrong? Its in "zsival(vname,value)". My idea is to be able to set variables from a source other than SMath Studio, such as a file.

Code:
    Public Function ExpressionEvaluation(root As SMath.Manager.Term, args()() As SMath.Manager.Term, ByRef context As SMath.Math.Store, ByRef result() As SMath.Manager.Term) As Boolean Implements SMath.Math.IPluginLowLevelEvaluation.ExpressionEvaluation
        Dim bResult As Boolean
        Dim sValue As String
        Dim dTerms As Term()
        Dim tTerms(0) As Term
        Dim answer As New List(Of Term)
        Dim i As Integer
        Dim j As Integer

        bResult = False
        sValue = ""

        If root.Type = TermType.Function And root.Text = "ztest" Then
            For i = args.GetLowerBound(0) To args.GetUpperBound(0)
                sValue = sValue + "i=" + Str(i) + ": "
                For j = args(i).GetLowerBound(0) To args(i).GetUpperBound(0)
                    sValue = sValue + " j=" + Str(j) + ": <" + args(i)(j).ToString + ">"
                Next
                dTerms = Decision.Preprocessing(args(i), context)
                sValue = sValue + vbCrLf + "i=" + Str(i) + ": "
                sValue = sValue + ListTerms(dTerms)
            Next
            MsgBox(sValue)
            answer.AddRange(Converter.ToTerms("1"))
            result = answer.ToArray()
            bResult = True
        ElseIf root.Type = TermType.Function And root.Text = "zsival" Then
            dTerms = Decision.Preprocessing(args(1), context)
            MsgBox(ListTerms(dTerms))
            context.AddDefinition(args(0)(0).ToString, dTerms, tTerms)
            answer.AddRange(dTerms)
            result = answer.ToArray()
            bResult = True
        End If

        Return bResult

    End Function
Ed
Offline Davide Carpi  
#4 Posted : 19 August 2013 03:34:50(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1331 time(s) in 876 post(s)
Good try using:

Code:
Dim tTerms(-1) As Term


instead of:

Code:
Dim tTerms(0) As Term
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 19/08/2013(UTC)
Offline TheWizEd  
#5 Posted : 19 August 2013 06:46:24(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
w3b5urf3r

That worked. Thanks much.
Ed
Offline Davide Carpi  
#6 Posted : 19 August 2013 11:37:50(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1331 time(s) in 876 post(s)
You're welcome, I'm glad to see you back in action Foto


Best regards,

Davide
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline TheWizEd  
#7 Posted : 20 August 2013 06:58:51(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Not sure if it matters but I made some minor changes to my code so an instance of the empty Term array was created instead of using the local variable array.

Replaced
Code:

        Dim tTerms(-1) As Term


with
Code:
      
        Dim tTerms As Term()
        tTerms = New Term() {}
        context.AddDefinition(args(0)(0).ToString, dTerms, tTerms)
Ed
thanks 1 user thanked TheWizEd for this useful post.
on 20/08/2013(UTC)
Users browsing this topic
Guest
Similar Topics
Problem with AddDefinition (Extensions)
by TheWizEd 18/08/2013 17:41:53(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.