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

Exponentiation Not Working???

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

    Exponentiation Not Working???

    I'm using this:

    (Inches + Feet * 12)*(Inches + Feet * 12)

    in a calculated field expression on a Dialog control because the exponentiation operators:

    (expression)**2 or (expression)^2

    just didn't work.

    What am I doing wrong?
    Is it me or is it Alpha5?

    #2
    Re: Exponentiation Not Working???

    Try this:

    (Inches + (Feet * 12))*(Inches + (Feet * 12))
    -Steve
    sigpic

    Comment


      #3
      Re: Exponentiation Not Working???

      Thanx, but that's not it:

      Arithmetic Operator Precedence

      An expression can include multiple arithmetic operators. Use parentheses to control the order in which the expression is evaluated. Alpha Five uses the following order of precedence when evaluating expressions:

      Operations enclosed in parentheses

      Exponentiation (^ or **)

      Multiplication and division (*, /)

      Addition and subtraction (+, �)

      Including operators in order according to their precedence allows parentheses to be implied when combining operations. For example, the expression 3 + 5 * 4 is equivalent to 3 + (5 * 4) since the multiplication operator has a higher precedence than the addition operator.

      Comment


        #4
        Re: Exponentiation Not Working???

        Well, then I guess I don't understand your question:

        Code:
        inches = 0
        feet = 1
        ?(Inches + (Feet * 12))*(Inches + (Feet * 12))
        = 144
        
        inches = 1
        ?(Inches + (Feet * 12))*(Inches + (Feet * 12))
        = 169
        
        feet = 2
        ?(Inches + (Feet * 12))*(Inches + (Feet * 12))
        = 625
        -Steve
        sigpic

        Comment


          #5
          Re: Exponentiation Not Working???

          If feet and inches are fields in your dialog, then they are character values. you need to convert them to numeric, then back to string. Normally, javascript doesn't care and does the conversion for you, but in this case, I believe it sees inches as character and is trying to concatenate.

          does just inches+feet*12 work by itself?

          If not, try
          val(inches)+val(feet)*12

          If that works, then you can square it.

          Pat
          Pat Bremkamp
          MindKicks Consulting

          Comment


            #6
            Re: Exponentiation Not Working???

            Good catch Pat. I was focused on the math and hadn't paid enough attention to where the values were established.
            -Steve
            sigpic

            Comment


              #7
              Re: Exponentiation Not Working???

              Guys:
              Thanx, for all your help, but we still do not have the answer.

              Here is the whole, working expression:

              Round(Pounds * 703.0696 / (Inches + Feet * 12) * (Inches + Feet * 12),1)

              The result matches other sources, so the math is right.
              BTW: This is the formula for Body Mass Index.

              Pounds, Feet and Inches are all local, numeric, textbox fields, in the dialog.
              If I try to say "val(inches), etc." the expression stops working.
              If I try to say "(Inches + Feet * 12)^2", it also stops working.
              If I try to say "(Inches + Feet * 12)**2", it also stops working.

              In a calculated field expression:
              It seems, that Alpha5 knows to convert these fields to numbers.
              It also seems, that fully qualified field names are not necessary.

              Why doesn't the exponentiation operator work???

              Comment


                #8
                Re: Exponentiation Not Working???

                E,
                either way it seems to work in the interactive---just going by what has been stated here I messed around and got both numeric and character values to come out using both ^ and ** . Unless you cannot test such things in the interactive editor????.....

                Regardless, try something VERY simple to see how it comes out....then build on that once it is working---I mean as simple as Pounds*10 even. Then build on it....easiest way to figure out where the problem lies. Also, just because the operands are supposed to work in the order stated, why take the chance or why not make certain that this is NOT the cause??
                Code:
                dim pounds as n
                dim inches as n
                dim feet as n
                dim result as n
                result=0
                pounds=10
                inches=10
                feet=10
                
                result=Round((Pounds * 703.0696)/ ((Inches + Feet * 12) * (Inches + Feet * 12)),1)
                ?result
                = 0.4
                
                result=round(Pounds * 703.0696 / (Inches + (Feet * 12))^2,1)
                ?result
                = 0.4
                
                result=round(Pounds * 703.0696 / (Inches + (Feet * 12))**2,1)
                ?result
                = 0.4
                ''================================================================
                
                dim pounds as c
                dim inches as c
                dim feet as c
                dim result as n
                result=0
                pounds="10"
                inches="10"
                feet="10"
                
                result=Round((val(Pounds) * 703.0696)/ ((val(Inches) + val(Feet) * 12) * (val(Inches) + val(Feet) * 12)),1)
                ?result
                = 0.4
                
                result=round(val(Pounds) * 703.0696 / (val(Inches) + (val(Feet) * 12))^2,1)
                ?result
                = 0.4
                
                result=round(val(Pounds) * 703.0696 / (val(Inches) + (val(Feet) * 12))**2,1)
                ?result
                = 0.4
                Mike
                __________________________________________
                It is only when we forget all our learning that we begin to know.
                It's not what you look at that matters, it's what you see.
                Henry David Thoreau
                __________________________________________



                Comment


                  #9
                  Re: Exponentiation Not Working???

                  Mike:

                  WOW! That's one tall, skinny, anorexic person!

                  Thanx for giving it a try.

                  The exponentiation operator may work in straight XBasic but apparently NOT in a field calculation expression of a dialog. I wonder if this is just not implemented in the interpreter. That would make it a BUG that should be fixed.

                  EZR

                  Comment


                    #10
                    Re: Exponentiation Not Working???

                    Exponentiation doesn't work in a v8 dialog either.

                    Submit a bug report with a simple example, please.
                    Al Buchholz
                    Bookwood Systems, LTD
                    Weekly QReportBuilder Webinars Thursday 1 pm CST

                    Occam's Razor - KISS
                    Normalize till it hurts - De-normalize till it works.
                    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                    When we triage a problem it is much easier to read sample systems than to read a mind.
                    "Make it as simple as possible, but not simpler."
                    Albert Einstein

                    http://www.iadn.com/images/media/iadn_member.png

                    Comment


                      #11
                      Re: Exponentiation Not Working???

                      Originally posted by Easy Rider View Post
                      I'm using this:

                      in a calculated field expression on a Dialog control because the exponentiation operators:

                      (expression)**2 or (expression)^2

                      just didn't work.

                      What am I doing wrong?
                      Is it me or is it Alpha5?
                      If you are entering this in the "calculated field expression" property under "Control Settings" for a textbox, any code in that expression must be valid JavaScript. That code runs only on the client computer and can not use any xbasic functionality, just JavaScript. Alpha Five does provide some JavaScript functions such as alltrim() that behave in a similar manner to the equivalent xbasic function, but the there is no built-in JavaScript support for exponentiation. JavaScript will not recognize ^ or ** as these as xbasic operators.

                      Comment


                        #12
                        Re: Exponentiation Not Working???

                        Originally posted by JavaScript will not recognize ^ or ** as these as [sic
                        xbasic operators.
                        Sounds like Alpha5 has room for improvement.
                        Thank you for answering this question for us.

                        I don't know JavaScript. Where can I get a tutorial guide/reference?

                        I could use a good book on Basic too...

                        Comment


                          #13
                          Re: Exponentiation Not Working???

                          Originally posted by Easy Rider View Post
                          Sounds like Alpha5 has room for improvement.
                          Thank you for answering this question for us.
                          You mean that Alpha has more room to fix all the problems of the other web stuff!

                          Originally posted by Easy Rider View Post
                          I don't know JavaScript. Where can I get a tutorial guide/reference?
                          http://www.w3schools.com/JS/default.asp

                          This is a quick start. Of course, Google is your friend. :)

                          Originally posted by Easy Rider View Post
                          I could use a good book on Basic too...
                          I will make the assumption you mean XBASIC not Basic. Good documents and tutorials are included with Alpha.

                          Comment


                            #14
                            Re: Exponentiation Not Working???

                            Since the calculated field expression on a Dialog control is being converted to Javascript, you can use Javascript functions - the expression convert is setup to recognize some basic Alpha functions, and convert them to there Javascript equivalents. The Javascript math function for "x to the power of y" is "Math.pow(x,y)". Therefore, if you create a dialog with three fields (all specified as numbers), named: "feet", "inches", and "sqInches"; and then set the calculated field expression of "sqInches" to "Math.pow((inches+(feet*12)),2)", you'll get the correct number in "sqInches".

                            This is a pretty good place to general Javascript info: http://www.w3schools.com/jsref/default.asp.

                            Eavan Chambliss

                            Comment


                              #15
                              Re: Exponentiation Not Working???

                              Thank you, Eavan:

                              I was just about to try and write my own "Power(x,n)" function. It would simply be a loop to do the multiplication n-1 times. This is what I think it would look like:

                              function Power(base, exponent)
                              {
                              var result = 1;
                              for (var count = 0; count < exponent; count++)
                              result *= base;
                              return result;
                              }

                              QUESTION: Could this function be defined, somewhere in my application, so that it could be called by the field calculation expression?
                              could it be defined and called IN the field calculation expression?

                              Thanx
                              EZR
                              Last edited by Easy Rider; 08-20-2008, 02:06 PM.

                              Comment

                              Working...
                              X