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

extract thousands digits

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

    extract thousands digits

    hi to all,

    i have tried to look for a function that will extract thousands digits to no avail.

    ex. 10,000.00 -> 10
    5,000.00 -> 5
    10000 -> 10
    10,000 -> 10
    100,000.00 will also give 100

    tia
    Francis

    #2
    Re: extract thousands digits

    Sometimes just a simple math calculation is all you need! ;)

    100,000 / 1,000 = 100

    You could make your own function for this to also test for values that you might not want to convert.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    Comment


      #3
      Re: extract thousands digits

      mograce,

      i was hoping that there is an alpha function for this since i am trying to escape from creating complex expressions to extract what i need. :D

      why does len() function fails to get the exact length of a converted numeric to string?...
      it always return a value of 10

      Code:
      a = "10000000000.00"
      ?a
      = 10000000000
      ?len(str(a))
      = 10
      Originally posted by MoGrace View Post
      Sometimes just a simple math calculation is all you need! ;)

      100,000 / 1,000 = 100

      You could make your own function for this to also test for values that you might not want to convert.
      Francis

      Comment


        #4
        Re: extract thousands digits

        Francis,

        What Robin was trying to tell you was to CREATE your own function!

        This is very easy to do and something that everyone should know how to do. It is done on the code tab and you only need one line in your function to make it work:

        function_name = INT(input_value/1000)

        Check out the docs as this is really easy to do.

        As for your LEN() problem it appears that you have dimensioned a as a numeric somewhere and that is why you are getting your results.

        From my interactive window:

        Code:
         
        a = "10000000000.00"
        ?a
        = "10000000000.00"
        ?len(str(a))
        = 14
        dim b as n
        b = "10000000000.00"
        ?b
        = 10000000000
        ?len(str(b))
        = 10

        Comment


          #5
          Re: extract thousands digits

          Robin,

          my apology... my brain did not function well the last time i was here... lol... (lack of sleep i guess)

          thanks.

          doug,

          thank you for the clarification...
          Francis

          Comment


            #6
            Re: extract thousands digits

            Francis, the STR() function returns the string equivalent of a numeric value. Unless you specify a length to return it defaults to a length of 10. Check the help file docs discussion for the STR Function. Here are some examples from the interactive window:

            Code:
            n = 1122334455667788
            ?str(n)
            = ""    (Fails because the string equivalent can't fit in 10 characters)
            
            ?str(n,16)
            = "1122334455667788"
            
            n = 12345
            ?str(n)
            = "     12345"  (Notice the leading blanks, req'd to pad length to 10 spaces?)
            Last edited by Tom Cone Jr; 06-28-2010, 07:23 AM.

            Comment


              #7
              Re: extract thousands digits

              Hi Francis,
              Perhaps my smiley was misinterpreted. You haven't told us any context for what you are trying to accomplish but your function could do this - depending on whether or not you want any decimals in the result:

              n=1234567890.12

              vc=alltrim(str(a/1000,20,5)) ' to omit decimals set to 0
              ?vc
              = "1234567.89012"

              vn=len(vc)
              ?vn
              = 13

              vc=alltrim(str(a/1000,20,0))
              ?vc
              = "1234568" 'notice it rounds up the result

              vn=len(vc)
              ?vn
              = 7

              Back to the original question:

              fn=100000

              rn=len(alltrim(str(fn,20,0)))
              ?rn
              = 6
              Last edited by MoGrace; 06-28-2010, 10:18 AM.
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment


                #8
                Re: extract thousands digits

                Tom,

                thank you for the detailed explanation for the str() function...

                Robin,

                it is a requirement on a report. i need to display how much is the current loan of a client in 2 digit format. i did asked "what if the client has a loan of 10,500?" he said "we don't release loans not divisible by 1000." funny isn't it?

                anyway, here are the screen shots...

                i'm still having problems with this report. undesired results in default columns... :(
                Francis

                Comment


                  #9
                  Re: extract thousands digits

                  Francis,
                  It's always harder than it sounds at first! I can see why you might need to get the length. Have you looked at substr() for how to display the digits?

                  Try something like this for your UDF:

                  Code:
                  FUNCTION knum AS N (vn AS N )
                  	vc = alltrim(str(vn,20,0))  'allowing for largest display for your numeric field.
                  	vnlen = len(vc)
                  	if vnlen > 3 then
                  		vnlen = vnlen-3
                  	    vckn = substr(vc,1,vnlen)
                  	end if 
                  	knum = val(vckn)
                  	
                  END FUNCTION
                  for your report you can just place your numeric field into the function to get the variable to display on the report. Assuming that variable is also numeric...

                  CL=knum(rel_det)

                  rel_det = 98500
                  ?knum(rel_det)
                  = 98
                  Last edited by MoGrace; 06-28-2010, 02:20 PM.
                  Robin

                  Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                  Comment


                    #10
                    Re: extract thousands digits

                    Francis,

                    try this one liner?

                    Code:
                    answer = (floor(floor(15999.00)/1000))
                    ?answer 
                    =  15
                    to have a 2 digit output is limiting to the future. as loans get larger 3 digits may be a must. I suggest making room for 3 just in case client starts lending more??
                    Last edited by DaveM; 06-28-2010, 03:24 PM.
                    Dave Mason
                    [email protected]
                    Skype is dave.mason46

                    Comment


                      #11
                      Re: extract thousands digits

                      If they don't release loans not divisible by 1000, then just divide by 1000. There are no fractions to be concerned with.

                      As an aside, you have:
                      A=month(transdate)
                      B=A+1
                      C=B+1
                      D=C+1

                      This is not good practice. This is better:

                      A=month(transdate)
                      B=A+1
                      C=A+2
                      D=A+3

                      Comment


                        #12
                        Re: extract thousands digits

                        You are the man Dave! Where did you find this function? lol. There is lots of help for character strings but searching for 'numeric expressions' does not list this one.
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment


                          #13
                          Re: extract thousands digits

                          Gabe, that was where we started until the len() issue arose. Which turns out should not be an issue at all now that we see what his data is.
                          Robin

                          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                          Comment


                            #14
                            Re: extract thousands digits

                            under help index

                            FLOOR()
                            Syntax
                            Integer_Result as N = FLOOR( Number as N )
                            Argument
                            Description
                            Number
                            A number.

                            Description
                            FLOOR() returns the largest integer that is either less than or equal to the specified Number.
                            Supported By
                            Alpha Five Version 5 and Above
                            Example
                            floor(12.3) -> 12
                            floor(-2.1) -> -3

                            See Also
                            Mathematical Functions
                            also

                            Mathematical Functions

                            Alpha Five provides the following Mathematical functions.

                            Function

                            Description

                            *AVERAGE()
                            V6
                            Returns the average of a CR-LF delimited list of numbers.

                            *COUNT()
                            V6
                            Returns the number of elements in a CR-LF delimited list.

                            *FROM_HEX()
                            V6
                            Converts a hexadecimal number into binary number.

                            *FROM_HEXC()
                            V6
                            Converts a hexadecimal number into a character string.

                            *FROM_HEXN()
                            V6
                            Converts a hexadecimal number to a decimal number.

                            *MAX()
                            V6
                            Returns the largest number in a CR-LF delimited list of numbers.

                            *MIN()
                            V6
                            Returns the smallest number in a CR-LF delimited list of numbers.

                            *TOTAL()
                            V6
                            Returns the total of elements in a CR-LF delimited list of numbers.

                            ABS()
                            V5
                            Returns the absolute value of a Number or numeric expression.

                            BYTES_TO_MEGA()
                            V6
                            Returns the KB, MB, GB, or TB equivalent of a byte number.

                            B_TO_KB()
                            V5
                            Converts a number to its equivalent in kilobytes.

                            CEILING()
                            V5
                            Returns the smallest integer that is greater than or equal to the specified Number.

                            CMTOINCHES()
                            V6
                            Converts a centimeter value to an inch value.

                            DEC_TO_HEX()
                            V5
                            Returns the hexadecimal equivalent of an integer.

                            EXP()
                            V5
                            Returns e raised to the power of the specified Exponent .

                            FLOOR()
                            V5
                            Returns the largest integer that is either less than or equal to the specified Number.

                            HEX_TO_DEC()
                            V5
                            Returns the integer equivalent of a hexadecimal number.

                            INCHES_TO_TWIPS()
                            V6
                            Returns the twips equivalent of a measurement in inches.

                            INCHESTOCM()
                            V6
                            Converts an inch value to a centimeter value.

                            INCREMENT_VALUE()
                            V5
                            Increments the value referenced by Variable by one.

                            INT()
                            V5
                            Truncates the decimal portion of the specified Number and returns the remaining Integer.

                            LOG()
                            V5
                            Returns the natural logarithm (base e) of the specified Number.

                            MAX()
                            V5
                            Returns the larger of two numbers.

                            MIN()
                            V5
                            Returns the smaller of two numbers.

                            MOD()
                            V5
                            Returns the remainder of the numerator divided by the denominator.

                            PIXELS_TO_TWIPS()
                            V6
                            Returns the twips equivalent of a pixels measurement.

                            POPUP.CALCULATOR()
                            V5
                            Displays a popup calculator and returns the result of the calculation.

                            RAND()
                            V5
                            Returns a random number between 0 and 1.

                            ROUND()
                            V5
                            Returns a Number rounded down to the specified number of Decimal_Places.

                            ROUND_DOWN()
                            V8
                            Returns a Number rounded down to the specified number of Decimal_Places.

                            ROUND_UP()
                            V5
                            Returns a Number rounded up to the specified number of Decimal_Places.

                            SIGN()
                            V5
                            Returns an Integer_Result representing the sign of a Number.

                            SQRT()
                            V5
                            Returns the square root of a positive Number.

                            TWIPS_TO_INCHES()
                            V6
                            Returns the inches equivalent of a twips measurement.

                            TWIPS_TO_PIXELS()
                            V6
                            Returns the pixel equivalent of a twips measurement.

                            VAL()
                            V5
                            Converts a Character_String to a numeric value.


                            Alpha Five provides the following Trigonometric functions.

                            Function
                            Description

                            ACOS() Returns the arc cosine of a Radian_Angle.
                            ASIN() Returns the arc sine of a Radian_Angle
                            ATAN() Returns the arc tangent of a Radian_Angle.
                            ATAN2() Returns the arc tangent angle in radians.
                            COS() Returns the cosine of a Radian_Angle.
                            DTOR() Converts Angle_In_Degrees (-180 to + 180) to an angle in radians (- and + ).
                            MATH_PI Math_PI is a global constant equal to the value of PI ( ).
                            RTOD() Converts an angle expressed in radians to an angle expressed in degrees.
                            SIN() Returns the sine of a Radian_Angle.
                            TAN() Returns the tangent of a Radian_Angle.
                            Dave Mason
                            [email protected]
                            Skype is dave.mason46

                            Comment


                              #15
                              Re: extract thousands digits

                              Duh, 'mathematical' who would a thunk? Not me apparently!

                              I'm just in here looking for fun stuff to try out in v10. But it is hard not to want to talk...
                              Robin

                              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                              Comment

                              Working...
                              X