Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, dr_panther, Quad), 935 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 25 of 32 1 2 23 24 25 26 27 31 32
Re: C# wrapper - RELEASE [Re: DJBMASTER] #316979
03/28/10 12:20
03/28/10 12:20
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
nope I've got no experience with 'var' smirk


get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: C# wrapper - RELEASE [Re: Stromausfall] #316983
03/28/10 13:23
03/28/10 13:23
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
oh ok, well I had only recently discovered it while reading a C# book. It allows implicit conversion...
Code:
var a = 45;
var b = 7.86;
var c = "hello world";
var d = false;


Maybe that could help you with automatic var handling?

Re: C# wrapper - RELEASE [Re: DJBMASTER] #316987
03/28/10 13:42
03/28/10 13:42
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
Would'nt there be some confusion between C# var and Acknex var?


A8.3x Commercial, AcknexWrapper and VS 2010 Express
○pararealist now.
Re: C# wrapper - RELEASE [Re: pararealist] #316988
03/28/10 13:48
03/28/10 13:48
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
I haven't looked up all the rules of the C# var, but maybe it could be used internally by the wrapper. Instead of the Var.IntValue and Var.FloatValue business.

Re: C# wrapper - RELEASE [Re: DJBMASTER] #317009
03/28/10 16:11
03/28/10 16:11
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
I see, Var.IntValue is a little too much sometimes, find myself forgetting them a lot, expecially when i return from C++ project.


A8.3x Commercial, AcknexWrapper and VS 2010 Express
○pararealist now.
Re: C# wrapper - RELEASE [Re: pararealist] #317470
03/31/10 20:38
03/31/10 20:38
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
the current Var object also allows implicit conversion for example
Var xx = 30;

but the main reason why 'Var' is indispensable at the moment, is, that certain functions like "pan_setneedle" take a REFERENCE to a variable !
and in c# it's not possible (at least not user friendly afaik) to get the reference to a value type, like int, var, or float !
and if one would only use implicit conversion, for example :

Var xx = 30;
and then give pan_setneedle the xx variable
and then for example change xx like this : xx = 400 + 70;
pan_setneedle would NOT take notice of the change, as xx references now to another new variable...

but nonetheless, the wrapper already uses implicit conversion, thus

float value1 = 3.4f;
int bla = minv(value1, 100);

and

int currentTimeStepValue = EngVar.time_step;
int currentTimeStepValue2 = EngVar.time_step.IntValue;

should work fine afaik!

I already tried to use ventilator's suggestion - lambda expressions, but they don't seem to be able to hold references to value types in c# frown


get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: C# wrapper - RELEASE [Re: Stromausfall] #317485
03/31/10 21:26
03/31/10 21:26
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
can you post some snippets of your lambda experiments? i have never seen lambdas in c# so it would be very interesting.

Re: C# wrapper - RELEASE [Re: ventilator] #317487
03/31/10 21:31
03/31/10 21:31
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
ooo, i thought getting a reference to a value type was as easy as supplying the 'ref' keyword...
Code:
public void ChangeMe(ref int i)
{
i++;
}
...
int x = 3;
ChangeMe(ref x);
// now x = 4


It's probably alot more complex than that, lol.
Lambdas seem pretty powerful, although havent really played with them.

Re: C# wrapper - RELEASE [Re: DJBMASTER] #317520
04/01/10 02:07
04/01/10 02:07
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
here's an example for a lambda expression in c# :
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lambdaTest
{
    class Program
    {
        delegate int getValueOfReference();

        static getValueOfReference newReferenceStorage = null;

        static void dummy(int valueInteger)
        {
            newReferenceStorage = () => { return valueInteger; };

            //that's how it should look like - but unfortunately doesn't work in c#
            //newReferenceStorage = () => { return refInteger; };
        }

        static void Main(string[] args)
        {
            int refInteger = 3;
            int valueInteger = 4;

            dummy(ref refInteger, valueInteger);

            valueInteger++;

            //when newReferenceStorage is called, the anonymous method is called..
            Console.WriteLine("variable : " + valueInteger);
            Console.WriteLine("lambda expresssion : " + newReferenceStorage());

            //give some time to read the output...
            Console.ReadLine();
        }
    }
}



Meanwhile I was able to further reduce the lines of code required for a experimental method (as mentioned : "at least not user friendly") which allows to store the reference of a value type. Although this method has some drawbacks :

1. the code needed from the user...

Code:
int dummyVariable = 3;



EngFun.pan_setvar(
  dummyPanel,
  1,
  1,
  delegate() { Reference.acquire(ref dummyVariable); }
);

//or (the same)

EngFun.pan_setvar(
  dummyPanel,
  1,
  1,
  () => { Reference.acquire(ref dummyVariable); }
);



2. for each variable that is stored, one thread needs to be created -> overhead smirk

3. the method pins/fixes the position of the variable in the memory, thus it disables the object, of which the variable is a member variable, to be moved from the garbage collector, which isn't preferrable....


My conclusion is that taking a reference from a variable still isn't a solution smirk
One way to deal with this problem would be, to remove the Var object alltogether and replace them with doubles (properties). And to create a special object/class for the panel functions that use a pointer to a variable - like the current Var object. Thus such a special class would only be needed for these panel functions, and everywhere else doubles (properties) would be used...

edit : -> thus the Var object would only be used in the panel functions that need a pointer to a variable..

Last edited by Stromausfall; 04/01/10 02:10.

get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: C# wrapper - RELEASE [Re: Stromausfall] #317537
04/01/10 07:58
04/01/10 07:58
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline OP
User
Stromausfall  Offline OP
User

Joined: Dec 2002
Posts: 616
Austria
Finally I got an idea, how to store references to a value type, without the need of a Thread. This method would/could use ventilator's suggested idea, of keeping an array for all variables that should be updated, in/because of these panel functions and update them at the beginning/end of a frame...
The downside is, that the code for the user to enter isn't that beautiful (two lambdas, if the panel function would read AND write into the variable)...
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class ReferenceStorage
    {
        public delegate double getValue();
        public delegate void setValue(double value);
        public getValue getValueLambda;
        public setValue setValueLambda;

        public ReferenceStorage(getValue getValueLambda, setValue setValueLambda)
        {
            this.getValueLambda = getValueLambda;
            this.setValueLambda = setValueLambda;
        }


    }

    class Program
    {
        /* this method should depict the engine, changing/reading through the reference */
        static void backgroundFunction(ReferenceStorage.getValue getValue, ReferenceStorage.setValue setValue)
        {
            /* 
             * if a permanent reference to that variable would be needed,
             * create a Reference Storage, to keep the two Lambda expressions
             * 
             * code :
             * 
             * ReferenceStorage newStorage = new ReferenceStorage(getValue, setValue);
             */


            while (true)
            {
                setValue(getValue() + 1);
                Console.WriteLine(getValue() + " increased, using lambda expression");

                System.Threading.Thread.Sleep(1500);
            }

        }

        /* a method that would be called from the user */
        static void dummyWrapperFunction(ReferenceStorage.getValue getValue, ReferenceStorage.setValue setValue)
        {
            System.Threading.Thread t = new System.Threading.Thread(
                () => { backgroundFunction(getValue, setValue); }
            );
            t.Start();
        }



        static void Main(string[] args)
        {
            double dummyValue = 30;

            /* call a dummy wrapper function and pass a 'reference' to the value type dummyValue 
             *
             * THIS is the code that user would have to enter, if the panel function would read AND write into the variable
             */
            dummyWrapperFunction(
                () => { return dummyValue; },
                (double newDummyValue) => { dummyValue = newDummyValue; }
            );

            while (true)
            {
                dummyValue += 1;
                Console.WriteLine(dummyValue + " increaesd, through directly increasing the variable");

                System.Threading.Thread.Sleep(1500);
            }
        }
    }
}



This could/would most likely be preferable over the two other options I mentioned, although it's not that easy for the user to use....

edit:
I'm currently always referring to double as the new variable type that could replace Var, but what I'm asking myself is, wouldn't a float suffice, as the value range of Var is already way smaller than float ?
pros for float in my opinion would be, a double isn't really needed and float should be faster in general than double I think
cons for float would be, that the usage of float is ugly to say the least... for example, the following statement is not allowed :
Code:
float bla = 30.2;


it has to be :
Code:
float bla = 30.2f;



Last edited by Stromausfall; 04/01/10 08:13.

get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Page 25 of 32 1 2 23 24 25 26 27 31 32

Moderated by  TWO 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1