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

Using Functions

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

    Using Functions

    HI All,

    In looking through the help file I found the "USPS_ZipCode_Lookup() function".
    It gives the following example to try in the interactive window:
    ? usps_zipcode_lookup("70 blanchard road", "burlington", "ma")
    = "01803-5100"

    The help files do not explain or give an example of how this could be used from a button on a form.
    I would think it could be done from a dialog box . I don't know where to start as I am not very familiar with Xbasic.
    Any help would be greatly appreciated. I would think that the help files would do a better job of helping someone new to Alpha or new to Xbasic get started.
    As in this example it shows the function you can try in the interactive window. But I have not found in the help files any instruction on using functions in your applications.
    Maybe I just overlooked it. Any suggestions as to how to best start at learning Xbasic?

    Thanks for any help or suggestions .......

    Carl

    #2
    Re: Using Functions

    The help files do not explain or give an example of how this could be used from a button on a form.

    I think the first step would be deciding what you want to accomplish. It may be that you don't even need a button.

    Suppose you are entering records on a form. You fill in the street address, city, and state abbreviation. Leaving the state field, you arrive at the zip code field. You want the user to have the opportunity to enter a zip but if they leave it blank, you want the function to fill in the zip.

    The ondepart event code for the zip code field, assuming the object name is zipcode ...


    if zipcode.value = ""
    zipcode.value = usps_zipcode_lookup(staddress.value, city.value, st_abbrev.value)
    end if

    If the street address field object name is staddress, the city field object name is city, and the state abbreviation field object name is st_abbrev.
    There can be only one.

    Comment


      #3
      Re: Using Functions

      Carl,

      try this in the interactive window:

      dim vadd1 as C ="70 blanchard road"
      dim vcity as C ="burlington"
      dim vstate as C = "MA"
      dim vzip as C

      vzip = usps_zipcode_lookup(vadd1,vcity,vstate)
      msgbox(vzip)
      You need to assign the output of the function to a variable or to the value of a field. If this was on a form, it might look like this reading the form field values into variables, given the field names are address1, city and state, and zipcode.

      Code:
      dim vadd1 as C 
      dim vcity as C 
      dim vstate as C
      
      vadd1 = parentform:address1.value
      vcity = parentform:city.value
      vstate = parentform:state.value
      parentform:zipcode.value = usps_zipcode_lookup(vadd1,vcity,vstate)
      Or the option of reading the field values directly from the underlying table given the field names are address1, city and state, zipcode:

      Code:
      dim t as p
      t=table.get("your_table_name_that_form_is_based_on")
      parentform:zipcode.value = usps_zipcode_lookup(t.address1,t.city,t.state)
      ....... and what Stan wrote.....
      Mike W
      __________________________
      "I rebel in at least small things to express to the world that I have not completely surrendered"

      Comment


        #4
        Re: Using Functions

        Thanks Mike for the alternative usage and comments.

        Carl,

        While usps_zipcode_lookup() may look intimidating at first, it is really no different or harder to use than say, upper().

        If you code the ondepart event code for a character form field with

        objectname.value = upper(objectname.value)

        then exiting the field will cause the contents of the field to be converted to uppercase.

        usps_zipcode_lookup() requires three parameters where upper only requires one but the principle is the same.
        There can be only one.

        Comment


          #5
          Re: Using Functions

          Stan & Mike W.

          I appreciate your explanations and examples given. I started out with action scripting and converted it to Xbasic. I created an Xdialog to gather the information and displayed the result in a msgbox. This is on the onpush event of a button with the idea that if I wanted to check for a zipcode while not entering data I could do so. I don't know anything about Xbasic so I am sure this could be cleaned up. Just wanted to share the code. With help from forum users like you who have the knowledge those like me will have an opportunity to learn.

          This is what I came up with. Any suggestion appreciated ........

          'Create an XDialog dialog box to prompt for address.
          DIM vadd1 as C
          DIM vcity as C
          DIM vstate as C
          DIM vzip as C
          DIM v_result as C
          heading_string = "Enter Address Information"
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          v_result = ui_dlg_box("Zip Code Lookup",<<%dlg%
          {region}
          {text=55,1:heading_string};
          {endregion};
          {region}
          Address:| [.40vadd1];
          City:| [.40vcity];
          State:| [.2vstate];
          {endregion};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%)

          'Conditional code follows. Executes only if the condition expression is True.
          IF a5_eval_expression("=Var->v_result=\"ok\"")THEN
          'Execute inline Xbasic code.

          vzip = usps_zipcode_lookup(vadd1,vcity,vstate)
          msgbox(vzip)
          END IF
          ------------------

          Again thanks to all on the forum, Keep it up.

          Carl

          Comment


            #6
            Re: Using Functions

            Good work Carl,
            Just a little cleaning, making it so you can enter through the text boxes, and a simpler result evaluation. Do you know about the code library. If not learn about it, and store this in there, maybe name it xDialog^zip_code_lookup, so you don't have to reinvent the wheel when you need it again, and you can use this as a template for others. With my memory being what it is, without the library I maintain, I would not be able to function.

            Code:
            DIM vadd1 as C
            DIM vcity as C
            DIM vstate as C
            DIM vzip as C
            DIM v_result as C
            dim dlg_title as C 
            	dlg_title = "Zipcode Lookup"
            heading_string = "Enter Address Information"
            ok_button_label = "&OK"
            cancel_button_label = "&Cancel"
            v_result = ui_dlg_box("Zip Code Lookup",<<%dlg%
            {on_key=enter}
            {region}
            {text=55,1:heading_string};
            {endregion};
            {region}
            Address:| [.40vadd1];
            City:| [.40vcity];
            State:| [.12vstate];
            {endregion};
            {line=1,0};
            {region}
            <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
            {endregion};
            %dlg%,<<%code%
            if a_dlg_button = "enter" then 
                if atc("!ok", ui_dlg_ctl_current(dlg_title)) > 0 then 
                    'user is on the OK button, so close the dialog
                else 
                    'user is not on the OK button, so advance to next control
                    ui_dlg_navigate(dlg_title,"Next")
                    'set a_dlg_button to null to keep the dialog open
                    a_dlg_button = ""
                end if 
            end if
            %code%)
            	select
            		case v_result = "Cancel"
            			end 
            		case v_result = "OK"
            			vzip = usps_zipcode_lookup(vadd1,vcity,vstate)
            			msgbox(vzip)
            	end select
            Mike W
            __________________________
            "I rebel in at least small things to express to the world that I have not completely surrendered"

            Comment

            Working...
            X