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

Return values from a FUNCTION

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

  • Return values from a FUNCTION

    I am using this FUNCTION: xyz as C (Vend,(PO,Err ) and i can not get the function to return any values!! I understood that in the function you could set XYZ to some character value and/or that you can change the values of PO and Err in the FUNCTION!! I just can not get this to work!! Can anyone show me the correct way to use a FUNCTION??? The FUNCTION does what it is supposed to do but will NOT return any values!!

    Don Walton
    352-243-3303

  • #2
    Re: Return values from a FUNCTION

    Can you post the function?
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.
    "Make it as simple as possible, but not simpler."
    Albert Einstein

    http://www.iadn.com/images/media/iadn_member.png

    Comment


    • #3
      Re: Return values from a FUNCTION

      Function xyz as c etc.

      last line is: xyz = whatever is desired
      end function

      That should cause it to return the value of xyz.

      like this:

      Code:
      function discretiontaxget as N(taxable as N,countytaxrate as N,max as N)
      dim mcountytax as n
      if   countytaxrate = 1.00 .and. taxable < max then
          mcountytax = taxable * (countytaxrate/100)
      elseif  countytaxrate = 1.00 .and. taxable >= max then
          mcountytax = 50.00
      elseif countytaxrate = .50 .and. taxable < max then
          mcountytax = taxable * (countytaxrate/100)
      elseif  countytaxrate = .50 .and. taxable >= max then
          mcountytax = 25.00
      elseif countytaxrate = .75 .and. taxable < max then
          mcountytax = taxable * (countytaxrate/100)
      elseif countytaxrate = .75 .and. taxable >= max then
          mcountytax = 37.50
      elseif countytaxrate = 1.25 .and. taxable < max then
          mcountytax = taxable * (countytaxrate/100)
      elseif countytaxrate = 1.25 .and. taxable >= max then
          mcountytax = 62.50
      elseif  countytaxrate = 0 then
          mcountytax = 0.00
      end if 
      discretiontaxget = mcountytax
      end function
      Last edited by DaveM; 11-11-2014, 11:58 PM.
      Dave Mason
      [email protected]
      Skype is dave.mason46

      Comment


      • #4
        Re: Return values from a FUNCTION

        This is what I did almost exactly!! The difference is that I tried to change the parameters that were sent to the function - in your case - taxable as N,countytaxrate as N,max as N!! Ie, setting taxable to a value etc!! It seems that the only values that can be returned are in the name of function - discretiontaxget!! Is it always just a SINGLE value that can be returned?

        Comment


        • #5
          Re: Return values from a FUNCTION

          Originally posted by DonWalton View Post
          This is what I did almost exactly!! The difference is that I tried to change the parameters that were sent to the function - in your case - taxable as N,countytaxrate as N,max as N!! Ie, setting taxable to a value etc!! It seems that the only values that can be returned are in the name of function - discretiontaxget!! Is it always just a SINGLE value that can be returned?
          Here is a pointer (pun intended) to some function help. Start on this page and then follow the 'See also' links

          Some examples
          Using with ... end with
          Code:
          dim txt as C = "aaa"
          dim num as N = 3
          dim lv as P = local_variables()
          
          msgbox("Local vars before", txt + "  " + num)
          msgbox("return from function",dosomething(lv))
          msgbox("Local vars after", txt + "  " + num)
          
          
          Function dosomething as C (lv as P)
          	dim text as C
          	dim numb as N
          	with lv
          		txt = "bbb"
          		text = txt
          		num = num * 2
          		numb = num
          	end with
          	dosomething = text + "  " + numb
          End function
          Using byref
          Code:
          dim txt as C = "aaa"
          dim num as N = 3
          
          msgbox("Local vars before", txt + "  " + num)
          msgbox("return from dosomething",dosomething(txt,num))
          msgbox("Local vars after dosomething", txt + "  " + num)
          
          
          dosomethingelse(txt,num)
          msgbox("Local vars after do something else", txt + "  " + num)
          
          
          
          Function dosomething as C(byref text as C, byref numb as N)
          		text = "bbb"
          		numb = numb * 2
          		dosomething = "something completely unrelated"
          End function
          
          Function dosomethingelse as V(byref text as C, byref numb as N)
          		text = "ccc"
          		numb = numb * 4
          End function
          Using a Pointer
          Code:
          dim result as P
          result = return_a_pointer()
          msgbox(result.Name + " lives in " + result.city)
          
          function return_a_pointer as P()
          	dim return_a_pointer as P
          	return_a_pointer.name = "Tim"
          	return_a_pointer.city = "Geelong"
          end function
          You could also return a crlf delimited string that contains a particular value on each line.
          You could take that further and put name:value pairs on each line.
          And using the flavour of the month you could return fully formed JSON
          Last edited by Tim Kiebert; 11-12-2014, 03:08 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


          • #6
            Re: Return values from a FUNCTION

            Don asked: Is it always just a SINGLE value that can be returned?
            Yes, that's right. But the "single" value might be a character string containing formatted data. The script that calls the function would then be responsible for parsing the string returned by the function.

            For example a function might return both a first and a last name, formatted as a single character string. Like this:

            "WALTON | DON"

            The string returned by the function could then be separated into first and last names.

            Comment


            • #7
              Re: Return values from a FUNCTION

              You can return more than one value from a function, but subversely.
              for instance:
              declare a variable as global, assign it a value in the function and the use the variable anywhere. I have one function that gives a car payment and then does all the other math and those numbers are either placed in variables or placed in fields on the form directly as they are computed.
              This way I have the interest and balance as well as the payment all complete.
              Like this:

              Code:
              FUNCTION pmtonapr AS N (p as n, r as n, mos as n, type as n, daystofirst as n)
              dim global balance as n
              dim global interest as n
              if r <= 0.00 then
                  pmtonapr = p/mos
              else
              dim df as n
              dim rte as n = (r/100)/12
              df = round_UP((daystofirst-30)/30,6)
              dim trm as n = 0
              dim formu as n
              'dim factor as n 
              var->factor = round_up((rte*df)*p,8) 'round_down() does not work in v7
              formu = round_up(p+var->factor,5)
              pmtonapr = round_down(pmts1(formu,r,mos),2)
                 
              end if
              var->balance = pmts*mos
              var->interest = var->balance-p
              
              end function
              Last edited by DaveM; 11-12-2014, 01:37 PM.
              Dave Mason
              [email protected]
              Skype is dave.mason46

              Comment


              • #8
                Re: Return values from a FUNCTION

                Tim

                Thank you for the reply!! I am definitely doing something wrong - when the FUNCTION ENDs and returns to the calling script, the name of the FUNCTION is always blank, IE does not contain the RESULT of the FUNCTION!! If I had a FUNCTION defined as XYZ as C (PO as C), the FUNCTION would set XYZ to a character result and the calling script,upon return from the FUNCTION, should be able to use XYZ and set it to a variable, for instance Char=XYZ!! I have tried so many things and I just cant get anything to work!!

                Comment


                • #9
                  Re: Return values from a FUNCTION

                  Thanks you!! Very helpful and I thank you!!

                  Comment


                  • #10
                    Re: Return values from a FUNCTION

                    This help me alot and I thank you!!

                    Comment


                    • #11
                      Re: Return values from a FUNCTION

                      Don,
                      Is this a web app you have or a desktop app?
                      Dave Mason
                      [email protected]
                      Skype is dave.mason46

                      Comment


                      • #12
                        Re: Return values from a FUNCTION

                        It is a desktop application!!

                        Comment


                        • #13
                          Re: Return values from a FUNCTION

                          Ok. This statement through me and is the reason for the question.

                          IE does not contain the RESULT of the FUNCTION!!
                          Dave Mason
                          [email protected]
                          Skype is dave.mason46

                          Comment


                          • #14
                            Re: Return values from a FUNCTION

                            To use the function like most functions:
                            from the calling script,
                            dim anyvar as c
                            anvar = xyz() and whatever calls are needed in zyz.
                            Like the pmt function above when called is like this.
                            Code:
                            var->vpmt = pmtonapr(var->vfinance+var->vdocs,mon->aprate,mon->term,mon->termtype,mon->daystofirst)
                            After, the variable "vpmt" has the results in it.
                            Dave Mason
                            [email protected]
                            Skype is dave.mason46

                            Comment


                            • #15
                              Re: Return values from a FUNCTION

                              Dave

                              If the name of the FUNCTION is XYZ as C() then when the function ends & returns to the calling script, XYZ should contain the result. Right? XYZ is always blank!!??!! Yet i knpow that the FUNCTION executed correctly - i watched it run with DEBUG() and XYZ contains the correct return but when I look at it in the calling program it is BLANK

                              Comment

                              Working...
                              X