Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Making a Class available to all your DBs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Making a Class available to all your DBs

    Want to make class variables automatically available to all your databases? I think I found the secret.

    I've found very little help on implementing Classes, but through quite a bit of trial and error I found out how to make a global/system class always available to all my databases. (And if you don't use classes, you're missing some HUGE benefits!)

    I found three secrets to making this work, and I'm still crossing my fingers:

    1) The help on Classes for v10 states "The last line of code that you paste must be 'end class'." That is absolutely correct, but you must add a carriage return after the 'end class' statement (I'm using 10.5 3432-3608, 64-bit Vista Home Premium). It would not work reliably for me without the carriage return.

    I could actually test the class with any extra code inserted after 'end class' -- every time I 'Save' the code it executes -- but when it was debugged and working, I had to comment out or delete all the other code and make sure 'end class' was the very last line of the file, terminated with a carriage return. Only then, and after compiling to an .AEX file and copying it into my addin directory, would it work.

    2) The help says to make the class 'global', but if you want it available to all your databases every time you must declare it 'system' instead.

    3) To use the class, you must first 'dim' an instance of that class with a simple 'dim' statement of any variable for that class - your code will fail if the first time your code uses the class is via a static method. Use 'dim myClassVar as MyClass' in your code, for example, prior to using 'dim myClassVar as p = MyClass.CreateNewMyClass()', otherwise you'll get a type-unknown error.

    If a couple of you could please confirm that this works, I'll add this into the code archive.

    Here's a sample class (to keep things simple and clean, create a new empty database and then create a new class with the class editor):

    Code:
    define class system Person
    dim lastname as c = "Smith"
    dim firstname as c
    
    function [static] NewPerson as p (Last as c, First as c)
    	dim NewVar as Person
    	NewVar.lastname = Last
    	NewVar.firstname = First
    	NewPerson = NewVar
    end function
    end class
    Make sure that 'end class' is followed with a single carriage return. And make sure the class is defined as 'system' rather than 'global', otherwise it will be available only to the database where it is defined.

    Then, follow the instructions to make an addin:

    http://wiki.alphasoftware.com/Compil...pile%20scripts
    http://wiki.alphasoftware.com/Managi...ghlight=addins

    Also check this:
    http://wiki.alphasoftware.com/Classe...+in+Version+10

    Close and restart AlphaFive (with further testing on my system, I don't need to do this).

    Then open any database where you want to use this class variable (or any other you've created that you want to be available always just like all other variable types). To use the class, your code path must encounter a simple dim statement first before the static method will work.

    To test this, enter:

    Code:
    dim test as Person	'you must do this first - if you comment this out, the next line will fail
    dim myFriend as p = Person.NewPerson("Jones","Bob")
    I hope this works for you - it's making my programming a lot better with a lot less typing and hassle!
    Last edited by EJR; 10-23-2010, 05:51 PM. Reason: typo
    There are three kinds of people in the world: those who can count, and those who can't.

    #2
    Re: Making a Class available to all your DBs

    Very Helpful, Thank You

    Comment


      #3
      Re: Making a Class available to all your DBs

      Eric,

      That looks like it might be very useful information. However, you said, "And if you don't use classes, you're missing some HUGE benefits!" but I'm willing to bet that 99% of Alpha users (including me) have absolutely no idea why they would ever want to use a 'class' - what would it be used for and what are some of those advantages??

      Specifically, what's the advantage over User Defined Functions (which are available to all applications if they are put in an aex file in the Addins_installed folder) and addin variables?

      If you can find the time, a brief writeup on that and/or some links to further info would probably be even more useful. I tried to find some links but wasn't very successful - "program class" certainly tends to find the wrong type of info. And, understandably, Alpha's Help files only describe how to use their commands - not how to write programs.

      I'm also wondering if the "Class" methods were added because that's what some people are used to and Alpha was just trying to make it user friendly for 'converts'. That may sound like an ignorant question - and it is because, as I said above, I don't know anything about using 'classes' and haven't been able to find any good links to learn more.

      Comment


        #4
        Re: Making a Class available to all your DBs

        when you start alpha and an adb and you declare and fill a system class, does it remain for other alpha startings and adb startings if the originating adb/alpha instance is closed?

        If it stays alive, I can see some strong potential. Actually, I can see potential anyhow.

        Is this system class accessible from othe applications(not alpha) once it is defined? (read/write/modify)?

        Classes have been around a long time, along with object oriented programming. I did not know alpha had the availability where it could exist outside the alpha program.

        Wish I had some time to explore this now.

        .
        Dave Mason
        [email protected]
        Skype is dave.mason46

        Comment


          #5
          Re: Making a Class available to all your DBs

          Cal,
          I have read about classes and here is a nice explanation.
          I too however am keen to understand from Eric what this can mean to developers in Alpha.

          Comment


            #6
            Re: Making a Class available to all your DBs

            Cal:
            Classes are EXTREMELY useful when you are dealing with data that has multiple attributes. Yes, you can certainly use UDFs and you do not have to use classes (well, I think I'll take back that statement - I think there are some things that require classes). A well-designed class can eliminate a lot of extra effort.

            I'll take you up on your suggestion and do a writeup for a class that makes displaying numbers in an Xdialog really cool. Then you can compare that with alternative implementations to accomplish the same thing. I'll post the code I'm using to test the class and include instructions on how to use it.

            In this number class (I call it 'clNumber' and I can define a new variable with 'dim MyNumber as clNumber') I right justify the number. During data entry you can enter commas, parentheses, and dollar signs, or the user can enter a complex equation, and it all formats properly. And if you use a Courier font for your numbers, they all line up properly.

            Whether you realize it or not, much of the functionality in AlphaFive is designed with class concepts. A member of a class "knows" what its features and limitations are. For example, when you open a table, the table pointer is a pointer to a class ("Table"). The open-file pointer allows you to fetch, change, enter, etc., and it "knows" that any function you call needs to work ONLY with that specific table you opened -- it knows how to work with itself. And any class you create behaves similarly, in that it knows its own attributes. (OK, that may sound fuzzy and funny, but once you have an example you can play with, you can catch on quickly.)

            A normal pointer variable that you can easily create can have multiple data components (such as 'dim t.name as c', dim 't.salary as n'). It's actually a simple class with data properties only, but you can't add any specific methods (UDFs, functions, whatever you want to call them) that work on that data. A class lets you add all the functionality you want.

            Dave:
            Once I create a class with 'system' scope, I can close AlphaFive. Then, I can open any of my databases and the classes I create are available (I don't yet know if I have to do something special to make them work in a runtime environment, but I assume they will work just fine). For dealing with Xdialogs, I had to add some code snippets in the 'library' so I could handle the Xdialog events (I just paste them in, no other changes needed). I'm trying to simplify that, but it will take a bit more time. I'll point this out in my sample.

            Garry:
            I'll try to post my clNumber class in a couple hours.
            Last edited by EJR; 10-25-2010, 12:50 PM. Reason: Typo
            There are three kinds of people in the world: those who can count, and those who can't.

            Comment


              #7
              Re: Making a Class available to all your DBs

              Classes known to most:
              Form
              Browse
              Table
              File
              etc...

              The classes I see in v10 are best understood if you realize that, for instance, when you are designing say a form, the dialog that appears with all the different tabs (properties) is a class and it is the same dialog whenever you open any DB.

              If you define a class for a particular purpose akin to that class, it will certainly save you a lot of time, assuming you will use it over and over.

              Comment


                #8
                Re: Making a Class available to all your DBs

                Gabe,

                You are totally correct.

                Think of a class made by a small a5 app that comes on at machine startup, sets up a/some class(es) and shuts itself off?? from then on the class(es) are available to any app running alpha adb's.

                Now, if a class is in system memory and can be used by other programs....? WOW

                What was it someone said about needing something done AFTER alpha was completely shut off??

                .
                Dave Mason
                [email protected]
                Skype is dave.mason46

                Comment


                  #9
                  Re: Making a Class available to all your DBs

                  OK, here is my code for what I call the clNumber class. It lets you edit formatted numbers in place, the columns are right-justified, and they all line up - all in an Xdialog box. Also, you can have a real 'Percentage' number where, if the value is 0.065, for instance, it will display as 6.500%.

                  I tried to document as much as I could - took me quite a bit longer today than anticipated. I wanted to be thorough.

                  If you haven't used Xdialog boxes before, stick with this for a bit. The format portion of the Xdialog code is only around 50 lines or so, and is very basic. The code section is a bit longer, but is pretty straight-forward code -- except for the eval() statements, which took me a while to figure out, but they are incredibly useful. In total it's a bit more than 600 lines, but I hope you can wade through it.

                  I'm expanding it and completing my classes for other variable types (currently, clDate and clTime). And I'm NOT planning to give those away, but feel free to use any of this attached code for any purpose, private or commercial or otherwise, royalty free with no derivative-rights retained by me. I'm doing some even-better stuff for myself! (I just hope this can help ignite a spark in some of you who were wondering how to do some of this stuff that I figured out over the last couple of weeks. Or maybe somebody might have some crazy money-making idea they want to talk to me about, who knows!!)

                  The exported code and a PDF document explaining it are attached. Enjoy and please comment!
                  Last edited by EJR; 10-26-2010, 12:15 AM. Reason: Added additional thoughts
                  There are three kinds of people in the world: those who can count, and those who can't.

                  Comment


                    #10
                    Re: Making a Class available to all your DBs

                    Hi Eric,

                    It's very impressive what you have created and what you share with us.
                    What a lot of work and very well documented.

                    For me it gives a new look at a (for me) unknown technique so I need time for investigation and understanding.

                    Thank you very much for this great contribution.

                    Ton
                    Most things are simple but unfortunately only after the first time

                    Comment


                      #11
                      Re: Making a Class available to all your DBs

                      Very nice, Eric.

                      Comment


                        #12
                        Re: Making a Class available to all your DBs

                        Thanks for taking the time to make this valuable contribution Eric.
                        -Steve
                        sigpic

                        Comment


                          #13
                          Re: Making a Class available to all your DBs

                          Originally posted by DaveM View Post
                          What was it someone said about needing something done AFTER alpha .
                          First time I read this.. it didn't click!
                          Glad you have good memory!
                          This might look like a riddle to the newcomers to the board.

                          Comment


                            #14
                            Re: Making a Class available to all your DBs

                            Originally posted by EJR
                            I founded: Gazelle Systems in the mid-80s (Q-DOS, Back-It, OptTune, and G-Edit) and PowerQuest in the mid-90s (PartitionMagic, Drive Image). I was the key architect of the core of each of those products.
                            PartitionMagic? I loved that program! Once I had a difficult problem and I called tech support at PowerQuest. I spoke w.a young woman who was the most knowledgeable technical support person I have ever spoken to. Very impressive all around.
                            Peter
                            AlphaBase Solutions, LLC

                            [email protected]
                            https://www.alphabasesolutions.com


                            Comment


                              #15
                              Re: Making a Class available to all your DBs

                              Thanks for the positive comments, guys.

                              Peter, my whole experience with PartitionMagic just blew me away. Incredibly fun memories going from an idea in my head to a successful company. That young lady you spoke with was one of around 400 employees we had before Symantec bought the company.

                              A lot of our tech support were programmers, many going to school in the evenings. And not a flunky among them (if so, they were VERY QUICKLY weeded out). We tried to make sure we had the best people we would find, and customer service was our main focus.

                              I just wish we had had a forum at the time like this one; it would have made many things much easier and better!
                              There are three kinds of people in the world: those who can count, and those who can't.

                              Comment

                              Working...
                              X