Results 1 to 15 of 15

Thread: New Addition in M2000 the Group command

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    New Addition in M2000 the Group command

    As I thinking to give access from M2000 to objects using createobject or some code from Lavolpe and others, It was clear to me that I needed a way to know about a list of variables, and type of them, before I use them. M2000 is an interpreter that read text and do process from that, and for simplicity in functions and modules (like subroutines) there is no description about the kind and the number of parameters passed. We place a READ command and we read from stack, a list of values, with no names, just values, strings or numbers. Each function has own stack and modules have shared stack (so if a module run in function, then that module see only the functions stack). There are some functions and commands like PUSH and DROP to manipulate the stack, so it is free to programmer to do what he like.
    For my goal to prepare list of variables in a way that we can check in position the type and value of it I make a very good addition. I make the Group object (and the appropriate command to make and handle it).

    Group object is an object that holds a list of variables and also functions that have defined in a module. We need this group object and the variables too. The group object can be passed by reference to the stack (references in M2000 are strings with variables names, using the namespace system of M2000). The Read command is the command that knows when we ask a reference from stack if that is a group and makes references for all variables, arrays, groups and functions, in the module or function where it run. Groups are like Objects, we can use static variables by using THIS.varname. For any group that we pass in a module or variable we have a new group and all the members of it as references. If groups are in the group the new groups defined. So a by reference pass for a group is not totally a list of references but also new "objects", with list for references too, for the inner object and for the outer too.
    For the static variables (this was not in my first idea but came as I coded the group logic) if we have a Group AA in a module A and we pass it in a module B and we make a reference to an id, say BB then the BB is take the position in THIS when the code of a function in AA run, say F(), run as BB.F(). The variables of BB and AA are the same, but the function F() "run" in an other module. maybe a module that we load, use and remove (that can be done in M2000). This function can use parameters from the new module and can even redim an array in AA Group. So we can expand "final" modules without altering basic code, and that is similar with objects. Groups and variables deleted when a module end. But if those are references..only the references deleted. In M2000 we can use part of module code as threads, as parts that run in intervals in background. That threads have also own stack as functions, but they are out of namespace, so any variables, and groups, are common to the constructor module. So maybe in a module we have some variables in groups that can be change from threads also. Another aspect is that the reference group reflects not only the real group but can hold new parts in own list.
    We have to distinguish a group from an object like objects in Vb6 because in Vb we have memory that are bound to object and we pass the reference along with the memory...and maybe the constructor terminate without erasing the object, because an active reference hold the object alive. In M2000, the group has variables that are same as all variables in the module. We can LIST the variables too. Only the Group object knows that these variables make a specific group, that object.The data on the group are modules data. We can use prototypes, strings that define groups, and we can make more groups using the same prototype. The group is live as the module that holds the variables are live. In specific situation, a module can change the module name inside, so we can use 2 or more banks of variables. There is a VALID() function to inform us if a variable exist.

    The group object is written in revision 4 of version 7 of M2000. You can read the source as provided at the bottom of the message.

    Here is a test code (written for a module a or use own name). Read comments on the code
    Code:
    Form 80,48
    group alfa {
          dim a(4)
          a(0)=1,2,3,4
          dim a(10)  ' this is a redim
          Document n$={1stline
          2ndline
          }
          a=23
          function hello$ {
                this.a =10     ' this is a new variable
                this.a <=100  ' this is the alfa.a, variable before "<=" interpreted as on the left hand in assign.
                this.a++   ' also  -- -!   += -= /= *=  work for a predefined variable
                list   ' just see the variables
                this.a(1)  = 200     
                = "hello"
          }
    }
    
    \* In a group we can place
    \* variables without values
    \* DIM                dim or redim arrays 
    \* LONG      a special constructor that make a double variable as a long variable (alter the variant inside)
    \* DOCUMENT  convert or make special strings, we can convert array items too
    \* FUNCTION  as in M2000 we didn't inform about how many or what type variables can we read in a function.
    \*                    we can put values or and references (and group references)
    \* MODULE   but we can't use THIS here, because Modules have a more light handle of name spaces..
    \* GROUP
    \* LONG   convert or make special number the LONG (4bytes) for using with DECLARE
    \* we can use THIS to read variables from a function to parent group
    
    Print dimension(alfa.a(),1)
    dim alfa.a(100)   ' this is a redim too
    Print dimension(alfa.a(),1)
    Print alfa.a(3), alfa.a
    Report alfa.n$
    read from alfa;
    stack 'we see the strings used for pointers on the stack 
    \* arrays are the last items in group'
    \* a group may have other groups inside
    \* so pointers are for variables including groups in groups
    \* no pointers return for functions.
    
    flush  ' erase all items from stack
    
    \* read normal read from stack but here read from group alfa
    \* only by reference, so not needed the & before any variable
    \* He have to place after alfa the right type and new variables
    \* M2000 can't replace reference in a variable that act as reference
    \* You get a message to try another name...for variable.
    
    read from alfa, ,doc$   'Here the comma  needed for the change in design.
    
    \* we read a reference to an obect DOCUMENT
    \* this is not a copy or a real reference but we have two or more variables
    \* to look to the same place where is the object. So what happen to object is
    \* known to all references.
    
    print doc.len(doc$), alfa.hello$()
    
    \* We can pass group references to modules or and functions. In each passing
    \* only names created and references to actual data, and  a new object created to hold the new list
    \* as a copy of the original object, because we can add more variables from inner module or function,
    \* and "parent" module never take any info for that (the additions deleted as we return to caller)
    \* So anything we do, reflect the real data. We can add more variables in a group, inside the module
    \* We can redim arrays in group for parent module too.
    
    \*A function in a Group leave only when run. So if we want to place same info for later use, we can use this to access variables in the group level, so we can place qualifiers to access variables in groups.
    \*Also we can add more variables:
    
    Group Beta {a, b=2, c, d=4}
    Group Beta {a=1, c=3, c$="OK"}
    Print valid(Beta.c$)
    Read from Beta, A1,B1,C1, D1, C1$
    Print A1,B1,C1, D1, C1$
    A1=1000
    Print Beta.a   'this is 1000 now
    Module TestMe {
          Read &BetaToo
          Read from BetaToo, A1,B1,C1, D1, C1$
          Print A1,B1,C1, D1, C1$
          \* we call this module twice, but the second time we have a k in Beta group, so in the reference.
          if Valid(BetaToo.k) then {
          {  ' we start a block so we can use preprocessor to replace . with BetaToo.
             \#. BetaToo.
                      Call   .Reset()
                      Repeat {
                            Print  .X(35,3)
                      } Until  .k>10
                 }
          }
    }
    TestMe &Beta
    Group Beta {
          k=0
          Function X {
                      this.k++
                      read a, b
                      =a*this.k+b
          }
          Function Reset {
          \* use <= not = because the second defines new variable...
          this.k <=0   ' use Call because we have no return value
          }
    }
    \* So using a Group we can make Static variables
    Repeat {
          Print Beta.X(10,5)
    } Until  Beta.k=10
    TestMe &Beta
    
    \* We can use prototypes as simple strings
    MyType$ ={
          Dim X%(100)
          Dim Y%(100)
          Group Inner {
          X ,  Y ,   Z     ' without values
          }
          Function Reset {
          }
    }
    
    Group Gama Type MyType$
    Group Delta Type MyType$
    for i=1 to 100 { Gama.X%(i-1)=i : Delta.X%(i-1)=101-i}
    For i=1 to 100 {      
    Group Gama {  X%(i-1)=Gama.X%(i-1)-Delta.X%(i-1)  }     ' so this is not nice - we can't use THIS (only in functions inside group)
    print gama.x%(i-1),
    }
    a(0)=1,2,3,4 do that
    a(0)=1
    a(1)=2
    a(2)=3
    a(4)=4
    We can make arrays with up to 10 dimensions, and this way put items from the starting item and above as the items are in memory (without using the dimension info, only look a "total" number as a finish limit)


    Revision 8, is uploaded with some fixes
    A change in the design of Group has done to simplify the member position in the group list. Now arrays have the position when entered in the group. So this affects the READ FOR group command and The output of MEMBER$() and MEMBER.TYPE$()

    Now Modules can see with THIS variables, arrays and other functions of Group.
    Now LOCAL before any member make this member not to be in the list so we can use it only at original group (in the module where we make it) and without any reference. With VALID(anything here) we can check if Group is running using a reference group and we can do some actions.
    Valid(this.var) return 0 if can't resolve the path to this.var.
    In M2000 references are strings containing names. So we can put a reference in stack, but to be a real reference we have to link in a variable. Links references to names doing from READ command. So if in stack we have this "A" then a Read &B try to link B with A. So if the linking done, then for one container we have two vars. We can't change B to link elsewhere. A linking is one time job for a variable.So for that reason we can't say the Groups as Objects. Objects have handlers or other bare pointers to memory. So objects can exist if a reference is there for it. Groups has a non reference existence, can only passed by reference, can contain arrays that we can redim, can contain modules and functions. So passing a group is like passing an object...we pass data and functionality with it.




    Have fun...
    M2000 is language for pupils and hobbyist..
    Last edited by georgekar; Dec 31st, 2014 at 07:25 AM. Reason: comments, for last revision 8

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    This can be written in a module too
    In Read command we say FROM and place a group, so we extract references from group to new names, using the order that we use to define them. We can omit same vars and make references for specific members.
    Code:
    form 80,48
    FLUSH
    group a {
          a=4
          group bb {
                c=34
                c1$="George"
                group dd {
                      d=45
                      e=13      
                      group chaos {
                            a=1
                            b=2
                            c=3
                            }
                }
                FUNCTION MINE$ {
                      READ A$
                      =A$ + " "+THIS.C1$
                }
          }
    b=5
    c=6
    dim a(20)=10
    document aa$="ok"
    }
    
    function count_member {
    read &a
    read from a;
    =stack.size
    }
    Read from a,  a1,Group2 ,,, Group3, , ,Group4
    LIST
    GROUP GROUP3 {
          K=67
          L=54
    }
    PUSH &GROUP3
    READ &ALL
    ? GROUP.COUNT(A),  count_member(&a)
    ? GROUP.COUNT(ALL), count_member(&all)
    FOR I=1 TO GROUP.COUNT(A) {
    PRINT MEMBER$(a,I), @(20),MEMBER.TYPE$(a,i)
    }
    ' These 4 variables are one (a.bb.dd.chaos.c)
    group4.c=1000
    ? group3.chaos.c
    ? group2.dd.chaos.c
    ? a.bb.dd.chaos.c
    ? group3.k  , valid(a.bb.dd.k)
    \* in group3 we make 2 more members local
    module TestMe {
          read &mygroup
          ? mygroup.mine$("Hello")
    }
    
    TestMe &GROUP2
    In this example the change of the position in the member's list has no errors. Just we see array to take position one before the end.
    Last edited by georgekar; Dec 8th, 2014 at 05:14 PM.

  3. #3
    Hyperactive Member Daniel Duta's Avatar
    Join Date
    Feb 2011
    Location
    Bucharest, Romania
    Posts
    396

    Re: New Addition in M2000 the Group command

    Hi George,
    You say that "M2000 is an interpreter that read text and do process from that" and in the Kristen`s thread you mentioned "Using GREEK you get error messages in Greek and using LATIN you get in English". I have written some usual english words and each time a message (I think an error message) "unknown identifier occurs. For this simple reason I think your application interface was not properly designed. You could consider a classic interface, with a clear menu, options, support commands.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    For installation you need to put in a folder 2 files, M2000.exe and Help2000.mdb
    You can use the ca.crt also to make it a root certificate if you wish to run it in windows 7 and later without security infos
    Latest revision is 7 so you can always read this readme file to see instructions and about the latest revision.

    ca.crt
    m2000.exe
    help2000.mdb
    source code

  5. #5
    Hyperactive Member Daniel Duta's Avatar
    Join Date
    Feb 2011
    Location
    Bucharest, Romania
    Posts
    396

    Re: New Addition in M2000 the Group command

    Thank you for your quick reply. I have read the readme file and still I am not able to work with your application. It looks like a DOS and even I typed "edit a" nothing happened. Actually, what is this interpreter. Is it a translator from greek to english and reverse, is it a character convertor from greek to latin or something like this ? Why didn't you modify the main form so that to make more readable all functionality of this tool ? Thank you.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    So you type edit a and nothing happen...??????
    in what OS??
    This language can operate databases, graphics, multimedia, a lot of things

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    The video above is from earlier version. Now many things changes but there is a compatibility with the old versions. I use a number of programs in m2000 to see if an error occur form a new version.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    Quote Originally Posted by Daniel Duta View Post
    Thank you for your quick reply. I have read the readme file and still I am not able to work with your application. It looks like a DOS and even I typed "edit a" nothing happened. Actually, what is this interpreter. Is it a translator from greek to english and reverse, is it a character convertor from greek to latin or something like this ? Why didn't you modify the main form so that to make more readable all functionality of this tool ? Thank you.
    It looks like computers from 80s. That is my scope. To start a pupil in a simplified world. I am curious about the "edit a" that you type. You forget to press enter? And then the textbox open and show you a flashing cursor...and then you can type a single command if you like SPEEVH "HELLO"
    press ESC (because enter add empty lines in editor), and you return in command line interpreter (same kind has the DOS), and you write a and press enter..
    I would like to see where you miss something??

  9. #9
    Hyperactive Member Daniel Duta's Avatar
    Join Date
    Feb 2011
    Location
    Bucharest, Romania
    Posts
    396

    Re: New Addition in M2000 the Group command

    Yes, indeed, the M2000 is a simplified world. I tried to type "edit a" both from exe file and from project, I pressed enter (OS Windows7) and the interpreter didn't return any thing. I was curious how it works. Fortunately I had the possibility to see your video. It is more than nothing. Was there someone outside of me who has tested this application ? Maybe this behaviour is related to some settings or files from your PC. Who knows.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    You didn't expect to get something from edit a, just open a textbox and you write in it.
    This language is using for years. When you do the "edit a" press any key..
    need vb6 Enterprise version.

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    Just see if settings works

  12. #12
    Hyperactive Member Daniel Duta's Avatar
    Join Date
    Feb 2011
    Location
    Bucharest, Romania
    Posts
    396

    Re: New Addition in M2000 the Group command

    So VB6 Professional is not good. When I typed "edit a" - of course, it doesn't matter what you try to edit - I didn't see any textbox, list or message. Simply it has no effect, whatever you key press. My suggestion is to speak with someone else and to check if the app has the same behavior.

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    Edit box has the same background with the screen so only the cursor you see. Cursor in edit box is a thin vertical line. In Cli (command line interpreter, cursor is a horizontal line).
    please write Settings and press enter...to open a form to change fonts, colors, and line spacing.

    Are you sure you use Vb6 (SP6)??

  14. #14
    Hyperactive Member Daniel Duta's Avatar
    Join Date
    Feb 2011
    Location
    Bucharest, Romania
    Posts
    396

    Re: New Addition in M2000 the Group command

    I have SP6 installed and even though Settings command does open a new window any change here has no effect. Sorry.

  15. #15

    Thread Starter
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: New Addition in M2000 the Group command

    Ok. As I understand the problem is in the use of user control glist4, in any combination (settings utilize this with some classes, to various controls, like dropdown list)
    The other fact is that M2000 works in every machine I know, except on your machine. M2000.exe didn't use common controls, so maybe I have to through the link to comctl32.dll at Main Sub...(you find InitCommonControlsEx), i think I didn't remove it for shell32, and maybe that is the cause of problem...but this is a speculation, i comment the commands in SUB MAIN,and I check it in Windows 7, so you can do it and see what happen). My thought is on the fact that you have the same fault in IDE. But in IDE you have no warning for something missing. So this is the sight we have to tell us that something going wrong with vb6 installation.

    Tell me if you can compile the code.

    George...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width