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

Using function in a calculation problems

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

  • #16
    Re: Using function in a calculation problems

    I'd try and have some error.
    Let me make it clear again.
    There is a condition by one of the calculation: If UnderBust is an even add 4" if the UnderBust is odd Add 5" if The UnderBust is in between Roundup
    Then I get a result number. This number I subtract fro Bust And if the difference is 1" then Cup size is "A" if 2" then "B" if 3" then "C" else "C"
    My problem is in the first part of the calculation and it's to add the correct number to UnderBust.
    I'll attached some image tha tyou can see the idee.(in mean time I put in my calculation a fix number (UnderBust +10.2cm)(4.5")
    calcimage.PNG
    CupCalc.PNG

    Thanks again
    Samuel

    Comment


    • #17
      Re: Using function in a calculation problems

      Code:
      var underBreast = {dialog.object}.getValue('UNDER_BREAST’);
      underBreast = Math.ceil(underBreast);
      var onBust = {dialog.object}.getValue(‘BUST’);
      var newUnderBreast = null;
      if (underBreast%2 == 0) {
         newUnderBreast = parseInt(underBreast) + 4;
      } else {
        newUnderBreast = parseInt(underBreast) + 5;
      }
      var cupSize = null;
      if (onBust - newUnderBreast == 1) {
           cupSize = 'A';
      }
      else if (onBust - newUnderBreast == 2) {
          cupSize = 'B';
      }
      else if (onBust - newUnderbreast == 3) {
         cupSize = 'C';
      else  {
         cupSize = ‘D’;
      }
      
      {dialog.object}.setValue(‘CUP’, cupSize);
      the round up was not mentioned earlier, so i modified the code.
      also with this javascript code, you do not need to calculate the cup size it will automatically insert in the cup field.

      when i get a chance i will look into how to get any in between number to up-round it.
      thanks for reading

      gandhi

      version 11 3381 - 4096
      mysql backend
      http://www.alphawebprogramming.blogspot.com
      ggandhi344@gmail.com
      Skype:ggandhi344@gmail.com
      1 914 924 5171

      Comment


      • #18
        Re: Using function in a calculation problems

        Originally posted by esamuel View Post
        I'd try and have some error.
        Let me make it clear again.
        There is a condition by one of the calculation: If UnderBust is an even add 4" if the UnderBust is odd Add 5" if The UnderBust is in between Roundup
        Then I get a result number. This number I subtract fro Bust And if the difference is 1" then Cup size is "A" if 2" then "B" if 3" then "C" else "C"
        My problem is in the first part of the calculation and it's to add the correct number to UnderBust.
        I'll attached some image tha tyou can see the idee.(in mean time I put in my calculation a fix number (UnderBust +10.2cm)(4.5")
        [ATTACH=CONFIG]40105[/ATTACH]
        [ATTACH=CONFIG]40106[/ATTACH]

        Thanks again
        Samuel
        Hey Samuel,

        What I don't quite follow is where your "either or" calculation is coming from for adding to the new underbust value. It sounds like there's more going on in your calculations than you've initially indicated and the screenshot really doesn't provide extra information as to what maths are involved. Though, maybe that's because the discussion is in inches but your images are showing cm.

        I put together a component that tries to do what you're describing. It uses Calculated Field Expressions to calculate the new underbust value as well as the cup size. Is this what you were looking for?

        EDIT: there was an error in my calculations if "cm" was selected from the dropdown. This zip contains the fixed version:
        underbust.zip
        Last edited by TheSmitchell; 04-09-2015, 12:11 PM.
        Alpha Anywhere latest pre-release

        Comment


        • #19
          Re: Using function in a calculation problems

          OK, That work.
          Did I say Genus?
          Now I have to figure out how and were to put it in my app.

          Thanks

          Comment


          • #20
            Re: Using function in a calculation problems

            Hi, Sarah,
            I implemented the code where it's belong, and it works.
            There is some changes that you can help me make:
            1) I need the default to be "cm"(I made changes in Unit control, but I need to change the JavaScript too, but the result was incorrect).
            let say I create client with data in "in" and like to see measurement in "cm" and going back to "in , the data was incrementing each time I made this changes.
            recordof .PNGrecordof1 .PNGrecordof2 .PNG
            I need to fix this incrementation.
            2) In the Calculation part You can see image , that when in "cm" the adding sum should be 10.2mm or 12.7mm , but it add 4" or 5" instead,( When the data is in "in" it's all correct.)
            Last edited by esamuel; 04-12-2015, 04:12 AM.

            Comment


            • #21
              Re: Using function in a calculation problems

              Originally posted by esamuel View Post
              Hi, Sarah,
              I implemented the code where it's belong, and it works.
              There is some changes that you can help me make:
              1) I need the default to be "cm"(I made changes in Unit control, but I need to change the JavaScript too, but the result was incorrect).
              let say I create client with data in "in" and like to see measurement in "cm" and going back to "in , the data was incrementing each time I made this changes.
              [ATTACH=CONFIG]40121[/ATTACH][ATTACH=CONFIG]40122[/ATTACH][ATTACH=CONFIG]40123[/ATTACH]
              I need to fix this incrementation.
              2) In the Calculation part You can see image , that when in "cm" the adding sum should be 10.2mm or 12.7mm , but it add 4" or 5" instead,( When the data is in "in" it's all correct.)
              Ah.

              What you need to do is convert the data coming in, which is in cm, to inches:
              Code:
              var cmInAnInch = 2.54;
              underbust = Math.ceil(underbust/cmInAnInch);
              Do all the calculations in inches, then at the end, convert it back to cm:
              Code:
              return newUnderbust * cmInAnInch;
              In the case of the cup size calculation, you don't need to convert back to cm since you're returning a string. But for the new underbust, you would need to convert back if you're displaying it.

              If you wanted to do all the math in cm, then you can't use the floor or ceiling functions for rounding. Nor can you use the modulo operator (%) based on your requirement that lengths are rounded to the nearest *inch*. The math operators would round your numbers to the nearest cm.

              If you want the math that adds the 4" or 5" inches to work with the original cm data, you can store your inches calculations in separate variables and add the cm values to the original data that was given to the function. Also, I'm making the assumption that you meant 10.2cm and not 10.2mm (10.2mm would be 1.2cm and way smaller than 4"). If this assumption is false, then 10.2 and 12.7 need to be changed to 1.02 and 1.27 below:
              Code:
              function calcNewUnderbustAlt (underbust) {
              	var cmInAnInch = 2.54;
              	var underbustIn = Math.ceil(underbust/cmInAnInch);
              	
              	var newUnderbust = 0;
              	
              	// FYI: this does not round the cm value UP to the nearest inch before
              	// adding 10.2 or 12.7. It just adds 10.2 or 12.7.
              	if (underbustIn == 0) {
              		newUnderbust = 0;
              	} else if (underbustIn % 2 == 0) {
              		newUnderbust = underbust + 10.2;
              	} else {
              		newUnderbust = underbust + 12.7;
              	}
              	
              	return newUnderbust;
              }
              I updated the component I posted earlier to do the conversion to inches before mathing if the data was cm values after recognizing that Math.ceil() on a cm value didn't round to the nearest *inch*.
              Alpha Anywhere latest pre-release

              Comment


              • #22
                Re: Using function in a calculation problems

                dam sarah, nice work!
                NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                Comment


                • #23
                  Re: Using function in a calculation problems

                  Code:
                  var measurement = {dialog.Object}.getValue('MEASUREMENT');
                  var bust = {dialog.Object}.getValue('BUST');
                  var underBust = {dialog.Object}.getValue('UNDER_BUST');
                  if (measurement == "centimeters") {
                  	bust = bust/2.54;
                  	underBust = underBust/2.54;
                  }
                  bust = Math.ceil(bust);
                  underBust = Math.ceil(underBust);
                  var newUnderBust = null;
                  if (underBust%2 == 0) {
                  	newUnderBust = parseInt(underBust) + 4;
                  } else {
                  	newUnderBust = parseInt(underBust) + 5;
                  }
                  var cupSize = null;
                  switch(bust - newUnderBust) {
                  	case 1:
                  		cupSize = 'A';
                  		break;  
                  	case 2:
                  		cupSize = 'B';
                  		break;
                  	case 3:
                  		cupSize = 'c';
                  		break;
                  	case 4:
                  		cupSize = 'D';
                  		break; 
                  	default:
                  		cupSize = 'Z';
                     }
                  {dialog.Object}.setValue('CUP_SIZE',cupSize);
                  here is the follow up on the code in post #17,
                  it depends on 3 fields: measurement ( can be inches or centimeters on a dropdown control), bust, underbust and sets the value of the cupsize based on the information provided.
                  thanks for reading

                  gandhi

                  version 11 3381 - 4096
                  mysql backend
                  http://www.alphawebprogramming.blogspot.com
                  ggandhi344@gmail.com
                  Skype:ggandhi344@gmail.com
                  1 914 924 5171

                  Comment


                  • #24
                    Re: Using function in a calculation problems

                    take a look at this screen implementing the code, also I think you have an error in your image
                    if you have bust 91 cm, under_bust at 74cm then the cup size should be B according to calculation I did.
                    http://screencast.com/t/txQXlkbpT
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    ggandhi344@gmail.com
                    Skype:ggandhi344@gmail.com
                    1 914 924 5171

                    Comment


                    • #25
                      Re: Using function in a calculation problems

                      Originally posted by GGandhi View Post
                      take a look at this screen implementing the code, also I think you have an error in your image
                      if you have bust 91 cm, under_bust at 74cm then the cup size should be B according to calculation I did.
                      http://screencast.com/t/txQXlkbpT

                      Thank you for a very nice explanation.
                      I'll put it to work and inform how it's going

                      Samuel

                      Comment


                      • #26
                        Re: Using function in a calculation problems

                        Originally posted by GGandhi View Post
                        take a look at this screen implementing the code, also I think you have an error in your image
                        if you have bust 91 cm, under_bust at 74cm then the cup size should be B according to calculation I did.
                        http://screencast.com/t/txQXlkbpT

                        Me again,
                        Can you please send me a zip file of this so I can see all details more clearly?!!

                        Comment


                        • #27
                          Re: Using function in a calculation problems

                          sorry sam I did not save the component I did not think you will need that.
                          the important aspect is the code, that I gave you. but if that is not enough, you sent me an email, so you have access to me. please send all the measurements and desired results. this weekend I will put together a dialog and zip it to you ( this will be the first time I am sending a component, hopefully I will do right). remember again this will be in version 11. no panel cards etc.,
                          Last edited by GGandhi; 04-29-2015, 05:49 AM.
                          thanks for reading

                          gandhi

                          version 11 3381 - 4096
                          mysql backend
                          http://www.alphawebprogramming.blogspot.com
                          ggandhi344@gmail.com
                          Skype:ggandhi344@gmail.com
                          1 914 924 5171

                          Comment

                          Working...
                          X