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

[ or ( - What's the difference?

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

    [ or ( - What's the difference?

    In reading the help files and documentation, I've noticed that almost always arrays are typed like this:

    ArrayName[n]

    Is there a difference between

    ArrayName[n] and ArrayName(n)? If so, what is it?

    Just curious.

    Charles

    #2
    RE: [ or ( - What's the difference?

    Charles

    Normaly when Alpha5 uses [] in describing the syntax
    of a function the brackets mean it is an optional argument.
    In which the actual [] is not included with the argument.

    In the case of an array it would seem that it is the proper
    syntax for defining the number of elements in an array.

    The [] accepts a numeric value only in the same way the {}
    brackets are used for dates. I am thinking that () accepts
    a character string thus to represent a numeric value
    enclosed in () would be trace.writeln(str(recno))to convert
    the numeric value to a character string.

    I havent tried to define an array using DIM arraynames(4) as C
    I believe that you would get an error using that syntax....
    but havent tried it to know for sure.

    Comment


      #3
      RE: [ or ( - What's the difference?

      I just put these four statements into my autoexec script and it ran without errors:

      DIM GLOBAL number(2) AS N
      DIM GLOBAL numbers[2] AS N
      DIM GLOBAL character(2) AS C
      DIM GLOBAL characters[2] AS C

      Then, in the Interactive window, I assigned variables to

      character(1), character[1], characters(1), characters[1], number(1), number[1], numbers(1), numbers[1], etc.

      then displayed them using ? and all of the variables were assigned.

      I know that [] in syntax statements ususally means optional. I just was curious why they were used for array indexes. It appears that it makes no difference at all which one is used.

      Thanks.

      Charles

      Comment


        #4
        RE: [ or ( - What's the difference?

        Charles,

        It may make no difference, but you should always try to use syntax as documented unless there is no other way. The reason for this is that, the program, in general, will try to match the documentation. In a new version or maintenance release, the alternatives may no longer work.

        Regards,

        Ira J. Perlow
        Computer Systems Design & Associates
        [email protected]
        Regards,

        Ira J. Perlow
        Computer Systems Design


        CSDA A5 Products
        New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
        CSDA Barcode Functions

        CSDA Code Utility
        CSDA Screen Capture


        Comment


          #5
          RE: [ or ( - What's the difference?

          I agree. I was just curious, though, because of these two pages from the xBasic help:

          Here, the documentation uses ().
          *************************
          DIM
          Syntax:

          DIM [SHARED] [GLOBAL] VariableName [(Array Size)] AS Value Type

          Description:

          Used to declare and allocate a variable. When declaring a variable as an array, you must supply the maximum subscript value in parenthesis. The variable type is indicated through the Value Type, a single character (N - numeric, D - date, C - character, L - logical, P - pointer, B - BLOB) at the end of the statement.

          You can ... (text omitted) ... sessions.

          Examples:

          DIM flds(256) AS C 'a 256 element array
          DIM SHARED flag AS L 'a shared variable called flag
          DIM field_value AS D 'a local value, explicitly declared

          *************************

          Now, over here, it uses []:
          ********************
          Defining An Array

          To store a series of data values of the same data type together under the same variable name, declare the variable as an array. Arrays are useful for collecting and processing lists of information. They must be explicitly defined with the DIM statement before they are used. The declaration must include the Array Size which is the maximum number of data elements the array will contain.

          For example, the following statement declares an array of character strings holding five elements:

          DIM names[5] AS C

          This array can be used to collect and store a list of five names. The contents of the array elements are assigned like any other variable using the assignment operator (=). The number of the element in which you want to put the data must also be supplied. For example:

          names[1] = "Henry"
          names[2] = "Burt"
          names[3] = "Ernie"
          names[4] = "Linda"
          names[5] = "Cheryl"
          ********************

          Sigh.

          Charles

          Comment


            #6
            RE: [ or ( - What's the difference?

            I've found a situation where it does make a difference. This piece of code reads an array glbMailName() of glbMailMax(2) elements and inserts glbMailName() as the choice and str(i) as the value of a radio button object:

            '*** START
            FOR i=1 to glbMailMax(2)
            IF i>1 THEN
            optDShip.CHOICE.LIST.INSERT()
            END IF

            ' CHOICE.LIST must be []
            optDShip.CHOICE.LIST[i].TEXT=glbMailName[i+10]

            ' CHOICE.LIST must be []
            optDShip.CHOICE.LIST[i].VALUE=STR(i,1,0)

            NEXT

            OptDShip.OBJECT.HEIGHT=glbMailMax(2)*.17

            '*** END

            What's strange is glbMailMax can use () or [] except for the very last line. It must be () here.

            Short of an answer from Those Who Know, I suppose [] should be used whenever an object is involved, and () used whenever a variable is involved.

            Charles

            Comment


              #7
              RE: [ or ( - What's the difference?

              Charles,

              I'm not buying what you said (without more proof). I would believe that [] would always work. What's the dimensioning or definition of glbMailMax(2). This looks more like a function call.

              All uses should be with brackets including the 1st line. The last line may be confused by the faulty definition in the 1st line.

              Regards,

              Ira J. Perlow
              Computer Systems Design & Associates
              [email protected]
              Regards,

              Ira J. Perlow
              Computer Systems Design


              CSDA A5 Products
              New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
              CSDA Barcode Functions

              CSDA Code Utility
              CSDA Screen Capture


              Comment


                #8
                RE: [ or ( - What's the difference?

                Ira:

                glbMailMax is numeric, dimensioned as global in my autoexec script:

                DIM GLOBAL glbMailMax[2] AS N

                It contains the total number of MailNames (currently 4) read in from a parameter table.

                glbMailName is character, dimensioned as global in my autoexec script:

                DIM GLOBAL glbMailName[20] AS C

                Merely changing the () to [] in the statement that sets the height of the radio buttons (optDShip) causes the height NOT to be set:

                OptDShip.OBJECT.HEIGHT=glbMailMax(2)*.17 'Works
                OptDShip.OBJECT.HEIGHT=glbMailMax[2]*.17 'Does not work

                I don't know the height of the radio buttons resulting from line 2 (it looks like 3 or 4 inches).

                Charles

                Comment


                  #9
                  RE: [ or ( - What's the difference?

                  Here is a small database that mimics the one I'm designing.

                  Charles

                  Comment


                    #10
                    RE: [ or ( - What's the difference?

                    Charles,

                    Alpha 5 may have a slight bug in syntax ininterpretation of the formula. The following do work. As far as I can tell, it's the combination of "]*" causing the problem. Other operators like "+" and "-" do not seem to cause a problem.

                    OptDShip.OBJECT.HEIGHT=(glbMailMax[2])*.17 'Does work OptDShip.OBJECT.HEIGHT=.17*glbMailMax[2] 'Does work

                    In general, when ever you have a syntax problem, it is wise to put extra parenthesis around each part to force Alpha to properly evaluate this.

                    I'm surprised that Alpha interpreted the line properly the other way, but I'll still stick by my original statement to use brackets for array references. By sticking with the brackets, any future corrections to the syntax will not fail your code.

                    Regards,

                    Ira J. Perlow
                    Computer Systems Design & Associates
                    [email protected]
                    Regards,

                    Ira J. Perlow
                    Computer Systems Design


                    CSDA A5 Products
                    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                    CSDA Barcode Functions

                    CSDA Code Utility
                    CSDA Screen Capture


                    Comment


                      #11
                      RE: [ or ( - What's the difference?

                      Ira:

                      Good advice. After posting the test.zip last night, I shut down and went to bed. This morning, before checking the forum, I tried

                      OptDShip.OBJECT.HEIGHT=glbMailMax[2]*.17

                      and it worked fine. I tried

                      OptDShip.OBJECT.HEIGHT=.17*glbMailMax[2]

                      like you did and it worked, too.

                      I wonder if A5 got a little unstable during my development work. I tend to make a lot of typing errors.

                      As a final question to this, is the variable assigned to an option button/check box/list box/etc. object restricted to being a character type, or can it be a numeric type? You might want to read msg. 45564 to see the background on this. I ask this because my option buttons always work when the variable is character, but they don't always work when it is numeric.

                      Thanks

                      Charles

                      Comment

                      Working...
                      X