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

SUBSTR QUESTION

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

  • SUBSTR QUESTION

    Dear Alpha programmer,

    My need should be simple, but not able to get my thinking right. Hope to get a quick help.

    My requirement as follow :
    1) Need to enter student id in 10 characters long
    2) Format is such 12345-67891
    3) When ID number start with leading zero ie : 01234567899
    should be treated as 01234-67899
    4) Below is the list of my basic codes.
    5) Problem I got is that when data of 1234567890 being entered will produced 12345-6789 with missing the last digit
    6) And when the leading zero is being used, it will produce
    ie : 0123456789 (10 digits long) will produce data as
    2345-6789 (I expect 01234-56789)

    0012345678 will produce 123-4567 (i expect 00123-45678)


    example of my code:
    SID=VAL(UI_GET_NUMBER("PSE ENTER STUDENT ID","PSE ENTER STUDENT ID"," "))


    STU_NUM.VALUE=SUBSTR(SSS,1,5)+"-"+SUBSTR(SSS,6,10)

    Can anyone help me with a correction.
    Thanks you and your assistance is greatly appreciated.

    Ken Tjia

  • #2
    RE: SUBSTR QUESTION

    Ken:
    if you want leading zeros, you can not use ui_get_number
    Numbers drop leading zeros.
    Why don't you create a script and then just play the script for the data entry.
    Example below

    DIM Global SID As C

    var->SID=""
    ' Prompts the user for a Student ID number
    ' -------------------------------------
    text_string = ui_get_text("SID", "Enter Student ID Number for Selection"," ","&&&&&-&&&&&")
    IF text_string = " " THEN
    ui_msg_box("SID", "Student ID Number invalid.")
    END
    ELSE
    var->SID = text_string
    END IF

    Charlie Crimmel

    Comment


    • #3
      RE: SUBSTR QUESTION

      Ken, let me elaborate on Charlie's idea.

      ui_get_number returns the result in a string of text characters.

      Your expression then uses the val() function to convert that string into a number. It's here that a leading zero in the char string gets tossed out. The string '00010' becomes the number 10 when the val() function finishes its work.

      So, when you get ready to parse the string, somewhere else, in code you don't show us, you must be converting the numeric value back into a string. When you do that using the STR() function, the number 10 becomes the string '10'. It will not restore the leading zeros. It will right justify the string result, padding the string with leading blanks, not zeros.

      Hope this helps.

      -- tom

      Comment


      • #4
        RE: SUBSTR QUESTION

        thank you both gentleman for your help.
        i should have realized ui_get_number will stripped "zero"
        that makes sense.

        Will try it this afternoon.

        Ken Tjia

        Comment


        • #5
          RE: SUBSTR QUESTION

          Ken,

          The ui_get_number() does not strip the zeros. As Tom Cone said, it's the val() function that does that.

          Here's a useful hint for future use:

          When not sure how a function works, go to the "Interactive" window in the code editor and try it there. Put a question mark in front of it to see the result as shown below:
          ?ui_get_number( "WHAT NUMBER", "Type your number", "000123" )
          If you run that in the interactive window and accept the default (000123) you should see this as the result:
          = "000123"

          Similarly, using the val() function you will see this:
          ?val( "000123" )
          = 123.000000

          If you need to run multiple Xbasic lines at one time, type them as one line and use a semi-colon to separate them. This is an example I used to run ui_beep() and find out how many times I needed to repeat the default beep so that it could be heard well:
          FOR x = 1 to 10; ui_beep(-1); NEXT x

          I even use this trick alot when building long messages using ui_msg_box(). Somehow the text never seems look the same in the real message box as I thought it would. (It appears correctly but it just doesn't "look right" to me.)

          Comment

          Working...
          X