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

Convert XD script to UDF and get a return value

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

    Convert XD script to UDF and get a return value

    Like I said, I am trying to convert various XD lookup scripts I have into UDF's. But I can't get the UDF to return a value other than blank.

    Ex:
    Function LU_Company AS C ( go_rec as C = "" )
    ....xd stuff working as expected...
    Lu_Company = go_rec
    End Function

    ?LU_Company()
    =""
    'or
    myvar = LU_Company()
    ?myvar
    =""
    The function renders a blank in the IW before the user even makes his selection.

    I am obviously missing something in how this ought to be done... I have other functions that return
    a value - but they are not using XD in them.

    In this particular script the user selects the company name to get the ID and based on the company type, opens a form for that type (eg. Customers have more stuff to display, Vendors don't).

    I want to make this a bit more generic so I can use the UDF in side other scripts where running a report instead of opening a form might be desired. So once the user selects his choice from the great looking
    XD I made - I can do whatever with the ID the function ought to return.

    Anybody have a similar working example?
    Last edited by MoGrace; 08-30-2014, 03:41 PM.
    Robin

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

    #2
    Re: Convert XD script to UDF and get a return value

    Don't see an issue.

    Function LU_Company AS C ( go_rec as C = "" )
    '....xd stuff working as expected...' maybe not
    go_rec = "ABC" assign value to go_rec
    Lu_Company = go_rec
    End Function

    ? LU_Company()
    = "ABC"
    There can be only one.

    Comment


      #3
      Re: Convert XD script to UDF and get a return value

      Maybe its where I put it in the script: after the ui_modeless_dlg_box() which is the next to last line, then
      lu_company = go_rec - which is the last line before the END FUNCTION

      I am tracing the changes to go_rec and it shows a value - plus the script opens the form to the correct record. It just won't return that value when I try it.
      Attached Files
      Last edited by MoGrace; 08-30-2014, 07:57 PM.
      Robin

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

      Comment


        #4
        Re: Convert XD script to UDF and get a return value

        Shouldn't it be

        --------------------------------------------------------------------------------
        'Date Created: 28-Aug-2014 06:16:28 PM
        'Last Updated: 30-Aug-2014 04:50:59 PM
        'Created By : Robin Q
        'Updated By : Robin Q
        FUNCTION LU_Company AS C (go_rec as C = "")

        not sure that would cause what you're seeing.
        There can be only one.

        Comment


          #5
          Re: Convert XD script to UDF and get a return value

          I would use debug(1) to trace what going on.

          and/or write to the trace window - always like to do that with xdialogs.
          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


            #6
            Re: Convert XD script to UDF and get a return value

            Stan - I tried both go_rec = "" as c and go_ rec as c ="" - it doesn't seem to make any difference.

            Al - I did write to the trace window and it shows the correct value for the variable. Something else is the matter here. I am not proficient with the debug feature.

            Who's our function guru here?
            Robin

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

            Comment


              #7
              Re: Convert XD script to UDF and get a return value

              The function is not returning a value because after firing up the modeless xdialog the function code continues and finishes before you get a chance to give 'go_rec' a value.
              Change this line:
              GoTo DirCode: [.15lu_list]
              to
              GoTo DirCode: [.15lu_list] GoTo DirCode: [.15go_rec]
              So you can see the go_rec value and then call the function with a value for go_rec. ie ?lu_company("zz")

              I am pretty sure I have a solution for you but I have to go find it in an app somewhere.
              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


                #8
                Re: Convert XD script to UDF and get a return value

                Thanks Tim, I will give it a go tomorrow
                Robin

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

                Comment


                  #9
                  Re: Convert XD script to UDF and get a return value

                  Found it.
                  But firstly, if you made this a modal (not modeless) dialog then the code would wait for the dialog to close and you would have access to the go_rec value. I am not suggesting that you do this, you most likely have it modeless for a reason, but mention it to say this is the way a modal dialog would behave. So we want to get the same behaviour out of a modeless dialog.

                  To the rescue comes UI_WAIT_UNTIL(). Add this in as below.

                  Code:
                  vResult = ui_modeless_dlg_box(dlg_title,dlg_rolldown,rolldown_code)
                  [COLOR="#0000CD"]WaitResult = ui_wait_until(ui_modeless_dlg_exist(dlg_title) = .f.,.1)[/COLOR]
                  LU_Company = go_rec
                  Ui_wait_until() will keep testing every .1 of a second (you can change this) if the dialog with a particular name exists. As soon as the dialog no longer exists the waiting ends and the code continues.

                  So this will now give the main function a value to return. I am curious why you want a value returned since you seem to be handling the choices within the xdialog code.
                  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


                    #10
                    Re: Convert XD script to UDF and get a return value

                    Hmmm, ok i reread your first post and it sounds like you want to change the purpose of this dialog a bit so that it only does the choosing of the ID. In this case you probably could change it to a modal xdialog and then the ui_wait_until function would not be necessary. The internals of the dialog code would need to be changed a bit to account for the way in which a modal dialog works. In the short term adding the ui_wait_until function may still be quicker.
                    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


                      #11
                      Re: Convert XD script to UDF and get a return value

                      Originally posted by MoGrace View Post
                      Stan - I tried both go_rec = "" as c and go_ rec as c ="" - it doesn't seem to make any difference.

                      Al - I did write to the trace window and it shows the correct value for the variable. Something else is the matter here. I am not proficient with the debug feature.

                      Who's our function guru here?
                      Debug(1) will show the timing of events better than the trace window.

                      It's hard for us to test without the table(s), forms, and code.
                      Last edited by Al Buchholz; 08-31-2014, 10:08 AM.
                      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


                        #12
                        Re: Convert XD script to UDF and get a return value

                        Thanks Tim for the suggestions. I can see why a modal XD would accomplish what the modeless XD doesn't. I guess I can' t have it both ways! What I can do is set a global variable with this function and use that instead of trying to get the return from the function itself. I am testing a few ideas to see which way might work better - now that I have the roll up feature working, it looked promising. Eenie meenie ....
                        Robin

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

                        Comment


                          #13
                          Re: Convert XD script to UDF and get a return value

                          Your welome Robin,

                          I have done similar using a global variable. In that case i use an xdialog with a tree control as an item picker setting a global variable. then a number of forms with different details on that item can be opened filtered for that item. The xdialog stays open permenantly docked to the side as a toolbar.
                          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


                            #14
                            Re: Convert XD script to UDF and get a return value

                            Tim,
                            That sounds like a context menu rather than 'just' a menu. Could you show me a screenshot?
                            Robin

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

                            Comment

                            Working...
                            X