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

What to do with the VAL Function

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

    What to do with the VAL Function

    Hi Guys
    I have a table with the following two fields:
    One Character field width 3 Value 17.45
    and a Numeric field width 10 decimal 2 that yields the Value 17.0 using the VAL function in the field rule.
    Yet when testing it in the interactive editor it produces the following results.


    dim NT as c
    NT = "17.45"
    ?Val(NT)
    = 17.45

    Am I missing something here?
    Any help with this one would be appreciated.

    Peter

    #2
    Re: What to do with the VAL Function

    One Character field width 3 Value 17.45
    Now that's really tough to do. I count four digits and a decimal in 17.45. How do you get that into a character field width 3?

    If you really want to test it in the interactive do something like this using your table and field names.

    Code:
    tbl = table.open("item")
    
    ? tbl.COST
    = 1.85
    
    ? tbl.cost_text= "1.85     "
    
    ? val(tbl.cost_text)
    = 1.85
    
    tbl.close()
    There can be only one.

    Comment


      #3
      Re: What to do with the VAL Function

      Stan
      My apologies, typo on my part its field width 5.

      Thanks

      Comment


        #4
        Re: What to do with the VAL Function

        yields the Value 17.0 using the VAL function in the field rule
        So what does this mean? You have a calculated field using val(character_field_name)?
        There can be only one.

        Comment


          #5
          Re: What to do with the VAL Function

          Hi Stan
          Tharacter field width is 5 and it has the value "17.45" this is how it gets imported from a CSV file.
          The calculated field width is numeric 10 with decimal 2
          It looks like the values in the numeric field column gets rounded of ie: 17.00

          Thanks
          Peter

          Comment


            #6
            Re: What to do with the VAL Function

            It looks like the values in the numeric field column gets rounded of ie: 17.00
            Where do you see 17.00? Browse column, form field? Check the format of either of those in the properties. Calculated fields don't automatically change to the proper format if you've been making some changes.
            There can be only one.

            Comment


              #7
              Re: What to do with the VAL Function

              Hi Stan
              I tried what you suggested in the interactive editor working directly from the table:
              Working with just the variable in the interactive editor:
              Code:
              dim vNT as c
              vNT = "13.17"
              ?VAL(vNT)
              = 13.17
              Working directly from the table in the interactive editor:(There are no forms involved)
              Code:
              dim tbl as p
              dim vNT as c
              tbl = table.open("fclock")
              vNT = tbl.NT
              ? vNT
              = "13:17"
              ?VAL(vNT)
              = 13
              Last edited by gagsoft; 08-13-2014, 01:35 AM.

              Comment


                #8
                Re: What to do with the VAL Function

                Stan is probably asleep so I will chime in. The problem is the semi colon. The val function converts a string representation of a number. The semi colon is a non numeric character so the conversion stops there and ignores the rest.

                These are examples from the help on val()

                val("12345") -> 12345
                val("abc234") -> 0
                val("1234abc234") -> 1234


                If the csv is supplying the semicolon (and you can't change that) then you can alter the calculated expression to change the semi colon to a period.

                val(strtran(NT,":",".")
                Last edited by Tim Kiebert; 08-13-2014, 03:07 AM.
                Tim Kiebert
                Eagle Creek Citrus
                A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                Comment


                  #9
                  Re: What to do with the VAL Function

                  Tim, has put his finger on the problem, but on this side of the pond we call ":" a colon. We reserve semi-colon for ";" <grin>

                  Comment


                    #10
                    Re: What to do with the VAL Function

                    Thanks guys
                    This is already in a dbf table after the import.
                    There is no semi-colon or colon in this field:-)
                    This is what I have in the field "
                    13:17"
                    What should the syntax be if the fieldname is NT.
                    Excuse my ignorance on the strtran function.
                    I do understand that the VAL() function will ingore everything after the dot based on the example.

                    Thanks

                    Comment


                      #11
                      Re: What to do with the VAL Function

                      There is no semi-colon or colon in this field:-)
                      This is what I have in the field "13:17"
                      I do understand that the VAL() function will ingore everything after the dot based on the example.
                      I see a colon between the 3 and the second 1. There is no dot in the example.

                      "13:17" is not a character representation of a number so val() can ony render the value of the digits up to the first non-digit character.


                      ? val("13.17")
                      = 13.17

                      ? val("13:17")
                      = 13
                      There can be only one.

                      Comment


                        #12
                        Re: What to do with the VAL Function

                        I'm with Stan (and Tim) on this one. Peter, maybe its time to head to the optometrist? <grin>

                        Comment


                          #13
                          Re: What to do with the VAL Function

                          Hi guys
                          I guess I do need to go see an optometrist or a bit of shut eye will also do:-)
                          But now that I see the colon, I have to work around it.

                          I could have used this.
                          Code:
                          ?VAL(STUFF("13:47",3,1,"."))
                          = 13.47
                          Or this
                          Code:
                          ?stritran("13:47", ":", ".", 1, 3, 1)
                          = "13.47"
                          But I am also presented with values like "9:05"

                          Thanks

                          Comment


                            #14
                            Re: What to do with the VAL Function

                            You're supplying optional parameters to strtran() that aren't necessary. All you need to do is replace the colon with a period.

                            ? stritran("13:47", ":", ".")
                            = "13.47"
                            ? stritran("9:05", ":", ".")
                            = "9.05"
                            ? stritran("14879:234821", ":", ".")
                            = "14879.234821"
                            There can be only one.

                            Comment


                              #15
                              Re: What to do with the VAL Function

                              Stan
                              Thanks.
                              I did not know exactly how the stritran worked and that it would accommodate strings with variable length.

                              Much appreciated.

                              Comment

                              Working...
                              X