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

How do you open Sub- UDF from parent UDF

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

    #16
    Re: How do you open Sub- UDF from parent UDF

    John:
    I am at loss!
    There is about 4 different questions in this thread.
    I will answer the first, the last and skip all in between.
    The first question (in the first post): The second function does not work because you didn't pass the variables to it.
    The last question (in the last post): The second "Einstein" function doesn't work because, for a starter:
    vPrdctId: who is vPrdctId? Where did he come from? and where does he live?
    I stopped there..let's clear this up first and go from there.

    Comment


      #17
      Re: How do you open Sub- UDF from parent UDF

      Hi,

      Well, Hmmm....

      I want to have a Calculated value which works with UDF so that I can add it as a field on the Browse.

      First --- I created an UDf which calculate an estimated value to Purchase Quantity.

      Function Est_poqty_calc as n (vPrdId as c, vEstQty as n, vEstUom as c )
      tPrd = table.open("prdcts",FILE_RO_SHARED)
      query.order=""
      query.filter="alltrim(prod_id) ="+quote(vPrdId)
      qPrd = tPrd.query_create()
      rPrd = qPrd.records_get()
      if rPrd>0 then
      vGrpId = alltrim(tPrd.Group_id)

      tGrp = table.open("Prdgrp",FILE_RO_SHARED)
      iGrp = tGrp.index_primary_put("Group_Id")
      rGrp = tGrp.fetch_find(vGrpId)
      if rGrp>0 then
      vSeriesId = alltrim(tGrp.Series_id)

      tSer = table.open("series",FILE_RO_SHARED)
      query.order=""
      query.filter="series_id="+quote(vSeriesId)
      qSer = tSer.query_create()
      rSer = tSer.Records_get()
      if rSer > 0 then
      vMtrType = alltrim(tSer.Mtr_type)
      'Conditions to calculate a vConvQty
      If vMtrType ="Dir" then
      vConvQty = vEstQty
      'Some other calcuation here
      else
      vConvQty = vEstQty * 2
      end if
      Est_poqty_calc = vConvQty +(vConvQty*.10)

      else
      'Shown the message by UI_msg_box()
      end if
      qSer.drop()
      tSer.close()
      end if
      qPrd.drop()
      tPrd.close()
      End Function
      Second -- I applied this UDf at Form's Calculated Values as like
      Code:
       
       xPoQty = Est_poqty_calc( Prdct_id,  EstQty, EstUom)
      Third --- Inserted the xPoQty from DragDrop List.
      Fourth -- Save it and changed the Enter View form Mode and It works fine so far.


      Now, I want to create an xdialog box at "Else" Conditions to calculate a vConvQty .

      Code:
       'Conditions to calculate a vConvQty 
                               [COLOR="#FF0000"]If vMtrType ="Dir" then
                                     vConvQty = vEstQty
                                     'Some other calcuation here
                              else
                                    'vConvQty = Est_Indirect_poqty (vEstQty, VestUom)  ' Not shown the code on here, However
                                    'I used the Ui_msg_box() Instead of the UDF because I am not sure that the code makes a trouble or not.
                                     ui_msg_box("test","Indirect material ")  'I think this Msg_box must be stop on end of the records.
      
                              end if
                                     Est_poqty_calc = vConvQty +(vConvQty*.10) [/COLOR]
      Now, the problem is that an xDialog(from else condition) or ui_msg_box() did not stop at all. I cannot save a form or close it.

      My question is why did the xDialog or msg_Box open all the time?


      Do you understand my problem now?

      Comment


        #18
        Re: How do you open Sub- UDF from parent UDF

        Yes, I do. The second function takes 2 parameters: vEstQty, VestUom
        Where and who fills in these parameters?
        Not you (not the user). Then who? and from where?

        Comment


          #19
          Re: How do you open Sub- UDF from parent UDF

          G

          I think from here, "Function Est_poqty_calc as n (vPrdId as c, vEstQty as n, vEstUom as c )"

          Comment


            #20
            Re: How do you open Sub- UDF from parent UDF

            No. It doesn't.
            Don't feel bad, it's a bit tricky, poorly documented and unnecessarily confusing. Here is one way to do it (of course, I ave no way of testing it):
            Code:
             Function Est_poqty_calc as n (vPrdId as c, vEstQty as n, vEstUom as c )
            tPrd = table.open("prdcts",FILE_RO_SHARED)
            query.order=""
            query.filter="alltrim(prod_id) ="+quote(vPrdId)
            qPrd = tPrd.query_create()
            rPrd = qPrd.records_get()
            if rPrd>0 then
            vGrpId = alltrim(tPrd.Group_id)
            
            tGrp = table.open("Prdgrp",FILE_RO_SHARED)
            iGrp = tGrp.index_primary_put("Group_Id")
            rGrp = tGrp.fetch_find(vGrpId)
            if rGrp>0 then
            vSeriesId = alltrim(tGrp.Series_id)
            
            tSer = table.open("series",FILE_RO_SHARED)
            query.order=""
            query.filter="series_id="+quote(vSeriesId)
            qSer = tSer.query_create()
            rSer = tSer.Records_get()
            if rSer > 0 then
            vMtrType = alltrim(tSer.Mtr_type)
            'Conditions to calculate a vConvQty
            
            If vMtrType ="Dir" then
            vConvQty = vEstQty
            'Some other calcuation here
            else
            x=local_variables()
            vConvQty=Est_Indirect_poqty(x)'I am guessing this second function will estimate vConvQty
            end if
            Est_poqty_calc = vConvQty*1.10)'I simplified this expression. It has nothing to do with your question
            else
            'Shown the message by UI_msg_box()
            end if
            qSer.drop()
            tSer.close()
            end if
            qPrd.drop()
            tPrd.close()
            End Function 
            
            Function Est_Indirect_poqty as v(vars as p)
            dim new_v1 as n=vars. vEstQty
            dim new_v2 as c=vars.vEstUom	
            	'whatevever this function does goes here
            end function

            Comment


              #21
              Re: How do you open Sub- UDF from parent UDF

              John,

              I continue to think the message box is opening all the time because the variable rser is not greater than zero. Why? See my earlier post in this thread. Your script will not stop to wait for the query to be run so that the record count of matching records can be discovered.

              May I suggest you use the trace window to display the rSer count immediately before the IF ... ELSE ... END IF code block. Does it show the value you are expecting?

              -- tom

              Comment


                #22
                Re: How do you open Sub- UDF from parent UDF

                G,

                Thank you for the POINT of problem.

                After applied your comment, I got an ERROR. A5 --- "Variable type Mismatch"

                Comment


                  #23
                  Re: How do you open Sub- UDF from parent UDF

                  This means your second function is now working but the variables are not dimmed properly or you are using them improperly.
                  I am suspecting the error is right at this line:
                  vConvQty=Est_Indirect_poqty(x)
                  As I said, I was guessing what the second function is supposed to do since you didn't say.
                  What is it supposed to do?
                  What is the actual code in the second function?

                  Comment


                    #24
                    Re: How do you open Sub- UDF from parent UDF

                    G,

                    This is what I did and
                    the 2nd UDf has an xDialog form and shows more detail (option) of the selections.
                    User can changes the selection.

                    Code:
                                             dim shared vConvQty as n
                                             If vMtrType ="Dir" then
                                                   vConvQty = vEstQty                               
                                             Else 
                                                   dim x as p
                    	                       x = Local_variables()
                    	                          'Est_Ind_poQty(x)  'Tried this
                    	                          'Est_PoQty_calc3 = Est_Ind_poQty(x) 'Tried this
                    	                       vConvQty = Est_Ind_PoQty(x) 'Tried this
                                             End If
                    
                    
                    Function Est_Ind_poQty [COLOR="#FF0000"]as N[/COLOR] (vars as p ) 'I tried "v" type
                    	dim vNew_EstQty as n = vars.vEstQty
                    	dim vNew_EstUom as c = vars.vEstUom
                    	vConvQty = vNew_EstQty * 2
                    	ui_msg_box("test","indirect materiasl "+vConvQty)
                    end function
                    The A5 Error message is now gone. but still the Msg_box() is shown and not able to close it.

                    Comment


                      #25
                      Re: How do you open Sub- UDF from parent UDF

                      What do you have to do to close the msg box?

                      As an aside, the second function Est_Ind_poQty has 2 arguments:
                      vEstQty N
                      VestUom C
                      What are you doing with VestUom in this function?
                      As another aside, I am questioning that's all the second function does! You don't need an UDF for that.

                      Comment


                        #26
                        Re: How do you open Sub- UDF from parent UDF

                        John and I were able to look at his code running in context. We are both a bit mystified.

                        Here's what's happening:

                        His UDF is being used in a calc display field in a set based form. That field is then displayed in the embedded browse that shows linked (1 to many) child records. The calculation uses column values from the same row, and "looks up" other values in external tables, to compute the desired figure.

                        The UDF behaves correctly unless he inserts a message box into the UDF code. If a message box is inserted then the form recalculates the calc display values in an endless loop. Something about the display of the message box causes the form to recalc the calc field in each row of the browse. Since that calc displays another message box, the recalc continues.

                        Wierd.

                        -- tom

                        Comment


                          #27
                          Re: How do you open Sub- UDF from parent UDF

                          Tom:
                          What do you have to do to close the msg box?
                          Did the last record in the browse calculate correctly but the msgbox remained open?

                          Comment


                            #28
                            Re: How do you open Sub- UDF from parent UDF

                            G,

                            Shut A5 down and Yes, It did Correctly

                            Comment


                              #29
                              Re: How do you open Sub- UDF from parent UDF

                              And which msgbox that remains open?
                              Code:
                              else
                              'Shown the message by UI_msg_box()
                              or
                              Code:
                              ui_msg_box("test","indirect materiasl "+vConvQty)

                              Comment


                                #30
                                Re: How do you open Sub- UDF from parent UDF

                                I don't think the usage of msgbox in a browse is appropriate as each row might have a different output for the UDF, meaning one row might have one msgbox, the next might have another and the third has none.
                                This is multiple personality syndrome on steroids.
                                The purpose of the msgbox is for user interaction, for "One Occurrence" at a time, for the user to interact with that occurrence, not for the masses.

                                Comment

                                Working...
                                X