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

Can enum be used in a UDF for a function parameter?

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

    Can enum be used in a UDF for a function parameter?

    Hi All

    Is it possible to use one of the enum functions to let me pick from choices in my UDF's instead of having to type certain choices out. For example, I have one function that uses the form name as a parameter I pass to the function and I was hoping to somehow use:

    a5.Form_Enum(2)

    By using the form enum funtion I was hoping to display a list(to me when implementing the function in my code) of the forms in the current app so I could just choose it from a list. I am basically wanting to duplicate Alpha's behavior on certain functions when we are allowed to right click and for example pick the DBF we want to use with the dbcount function.

    Thanks...

    Jeff

    #2
    Re: Can enum be used in a UDF for a function parameter?

    Hi Jeff,

    Originally posted by jkletrovets View Post
    Hi All
    Is it possible to use one of the enum functions to let me pick from choices in my UDF's instead of having to type certain choices out. For example, I have one function that uses the form name as a parameter I pass to the function and I was hoping to somehow use:

    a5.Form_Enum(2)

    By using the form enum funtion I was hoping to display a list(to me when implementing the function in my code) of the forms in the current app so I could just choose it from a list. I am basically wanting to duplicate Alpha's behavior on certain functions when we are allowed to right click and for example pick the DBF we want to use with the dbcount function.
    It is possible, but not easy. See this thread Re: UDF Parameters lookup where it was discussed.

    It is easiest, when you can use Alpah's built-in ones by using the same or similar parameter names.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture


    Comment


      #3
      Re: Can enum be used in a UDF for a function parameter?

      Hi Jeff

      As Ira says, try to use Alpha's built-in parameters. For forms the form_name parameter should work.

      e.g
      Code:
       
      FUNCTION form_zzTest2 AS C (form_name AS C )
           ui_msg_box("","Form Name Is:- "+form_name)
      END FUNCTION
      If It Works First Time, There's Something Wrong!!!

      Comment


        #4
        Re: Can enum be used in a UDF for a function parameter?

        Thanks Ira and Chris!

        I appreciate it. That gets done exactly what I wanted to do (using Alpha's built in ones).

        Interesting possibilities with everything discussed in that thread as well.

        Thanks again....

        Jeff

        Comment


          #5
          Re: Can enum be used in a UDF for a function parameter?

          This one got me thinking about other uses. So why not do it along the lines of the original conception?

          Dump all this code into a single script.

          Code:
          '============================================
          DIM shared TType as C
          DIM shared varC_result as C
          'insert another xd here with a dropdown of the types you want to process
          'For now just use form
          thistype = "Form"
          ShowType(thistype)
          if varC_result = "OK" then
              ui_msg_box("","Selected " + ttype)
          end if
          '=============================================
          FUNCTION ParseType AS C(AType as C,Name = "" )
          'Pass the alpha "type" to the function so that it can be parsed
          'if the type and name are passed just process the name
          if alltrim(name) <> "" then
           'do something with this object
          end if
          'get the list
          dim objlist as c
          ParseType = alltrim(sortsubstr(eval("A5." + AType + "_enum(2)"),Crlf(),"A"))
          END FUNCTION
          '=============================================
          Function ShowType as C(BType as C)
          dim shared ttype as c
          auto_list_TType = ParseType(Btype)
          temp_count = w_count(auto_list_TType,crlf())
          DELETE a_TType
          DIM a_TType[temp_count] as c
          a_TType.initialize(auto_list_TType)
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          dlg_title = "Select"
          dlg_code=<<%dlg%
          {region}
          Select:| [%v%.37TType^+a_TType];
          {endregion};
          {line=1,0};
          {region}{justify=center}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%
          
          event_code=<<%code%
          if a_dlg_button = "Cancel" then
              g1 = ui_msg_box("","Nothing selected." + Crlf(2) + "Continue to exit?",ui_yes_no)
              	if g1 = ui_no_selected then
              	    a_dlg_button = ""
              	end if
          end if
          %code%
          varC_result = ui_dlg_box(dlg_title,dlg_code,event_code)
          END FUNCTION
          '=============================================
          Just a thought.
          Finian

          Comment


            #6
            Re: Can enum be used in a UDF for a function parameter?

            Yup,
            I made this one for a section of a function which allows a choice of db tables and then presented with the table fields, similar to the code editor's code> insert field name menu option. Thought I would throw this in the mix.

            Code:
            ' get list of the current tables
            dim vTM as C=""
            vTM = a5.table_enum()
            dim vFM as C=""
            
            '======== generate the xDialogs ===================
            dim tablename as C
            dim fieldname as C = "Field Name"
            dim shared vdy as C
            
            	dlg_text = <<%dlg%
            	{position=1.5,2.5}
            	{background=#170,200,175}
            	{xmargin=2,2}
            	{font=Arial,9,b}
            	{frame=1,1: Tables and Fields}
            	{font=Arial,9,n}
            	{region}
            	[.25,20tablename^#vTM!tc_*] {sp} | [.25,20fieldname^#vFM!fc_*]
            	{endregion};
            	{lf};
            	{condition=.t.}
            	{line=1,0}
            	{lf};
            	{justify=center}<10OK> <10Cancel>
            	%dlg%
            	
            	dim vresults as C 
            RETRY:	
            	vresult=ui_dlg_box("Item Choices", dlg_text, <<%code%
            
            	' this is for a trapping a change in the tablefield box
            	IF left( a_dlg_button, 3 ) = "tc_"
            	 IF a_dlg_button = "tc_change"
            	 	vFM = sortsubstr(w_upper(lower(table.external_field_name_get(tablename,"N"))),crlf(),"a")
            	 END IF
             		 a_dlg_button = ""
            	END IF
            	%code%)
            	
            	' process selections
            	if vresult = "Cancel"
            		end
            	else if tablename = ""
            		ui_msg_box("SELECTION ERROR","There was no table selected. Please try again",48)
            		GOTO RETRY
            	else if fieldname = "Field Name"
            		ui_msg_box("SELECTION ERROR","There was no field selected. Please try again",48)
            		GOTO RETRY
            	end if
            
            msgbox("Choices","Table = " + alltrim(tablename)+crlf()+"Field = " + alltrim(fieldname))
            Mike W
            __________________________
            "I rebel in at least small things to express to the world that I have not completely surrendered"

            Comment


              #7
              Re: Can enum be used in a UDF for a function parameter?

              Holy Cow! Maybe I truly am the only one in Alphadom that likes to see fields listed in natural order. My reasons:
              (A) I tend to group them by things like --> "key fields" (at the beginning), "address info", "phones", "shipping info", "billing info", "special price info", "contact info", etc. Sometimes, having them scattered all over in the list is a pain.
              (B) new fields are almost always added at the end of the table but I don't always remember the name of those newer fields. Searching for "I don't remember the field name" alphabetically is rather difficult.

              This has been one of my pet peeves with A5 for a long time. Some dialogs only show fields in alphabetic order, some only show them in natural order, and a few actually allow the developer a choice. I think they should ALL allow a choice - something that should be very easy to do. It was certainly easy to do here.

              And, yes, sometimes I do like to see them presented alphabetically. I just want the choice!

              Here's a revision to Mike's script that allows the user to choose the sort order. It is also modified to eliminate the "Restart" and just keep it in the dialog unless the user selects both the table and field name: (script layout reformatted with my free Script_Formatter)
              Code:
              ' get list of the current tables
              DIM vTM as C = ""
              vTM = a5.table_enum()
              DIM vFM as C = ""
               
              '======== generate the xDialogs ===================
              DIM tablename as C
              DIM fieldname as C = "Field Name"
              DIM SHARED vdy as C
              sort_alpha = .T.
              
              dlg_text = <<%dlg%
              {position=1.5,2.5}
              {background=#170,200,175}
              {xmargin=2,2}
              {font=Arial,9,b}
              {frame=1,1: Tables and Fields}
              {font=Arial,9,n}
              {region}
              {font=Arial,8,b} Select Table: | Select Field:{font=Arial,9,n} (sort_alpha!tc_*?tablename!="")Sort Alpha;
               [.29,20tablename^#vTM!tc_*] | [.29,20fieldname^#vFM!fc_*]
              {endregion};
              {lf};
              {line=1,0}
              {lf};
              {justify=center}<10OK> <10Cancel>
              %dlg%
              
              DIM vresults as C
              vresult = ui_dlg_box( "Item Choices", dlg_text, <<%code%
              ' this is for a trapping a change in the tablefield box
              IF left( a_dlg_button, 3 ) = "tc_"
              	IF a_dlg_button = "tc_change"
              		IF sort_alpha
              			vFM = sortsubstr( w_upper( lower( table.external_field_name_get( tablename, "N" ) ) ), crlf(), "a" )
              		ELSE
              			vFM = w_upper( lower( table.external_field_name_get( tablename, "N" ) ) )
              		END IF
              	END IF
              	a_dlg_button = ""
              ELSEIF left( a_dlg_button, 3 ) = "fc_"
              	IF a_dlg_button = "fc_change"
              		a_dlg_button = "OK"
              	ELSE
              		a_dlg_button = ""
              	END IF
              END IF
              IF a_dlg_button = "OK"
              	IF tablename = ""
              		ui_msg_box( "SELECTION ERROR", "There was no table selected. Please try again", 48 )
              		a_dlg_button = ""
              	ELSEIF fieldname = "Field Name"
              		ui_msg_box( "SELECTION ERROR", "There was no field selected. Please try again", 48 )
              		a_dlg_button = ""
              	END IF
              END IF
              %code% )
              
              ' process selections
              IF vresult <> "OK"
              	END'
              END IF
              
              msgbox( "Choices", "Table = " + alltrim( tablename ) + crlf() + "Field = " + alltrim( fieldname ) )
              Last edited by CALocklin; 05-15-2009, 01:50 PM. Reason: Fixed problems with my original script changes.

              Comment


                #8
                Re: Can enum be used in a UDF for a function parameter?

                Cal,
                Excellent addition, thank you. It works perfectly in my hands. Yes, I group fields in the table also, and this does assist in locating the desired field. Nice job.
                Mike W
                __________________________
                "I rebel in at least small things to express to the world that I have not completely surrendered"

                Comment


                  #9
                  Re: Can enum be used in a UDF for a function parameter?

                  Sorry for my delay in responding back to this post....I have been out of town.

                  This is VERY cool stuff and in my mind opens up a whole new area of possibility for my functions. Yes Ira...you have turned me into a function fanatic now! :)

                  I am working on a "framework" that I will use to start every application that contains my core application functions (auto-increment, custom req'd field checking, opening child table data entry forms, a couple standard "starter forms" etc.)

                  I have not had a chance to test this yet but if I am reading all the posts correctly.....then I should be able to just call these various enum functions in the following section in my function:

                  addin.function_argument_help
                  Does that sound correct?

                  So, a typical use for me might be something like this in a UDF called AddChild():

                  From the help file...
                  <FORM> as P = FORM.LOAD( Form_Name as C [, Style as C [, Window_Name as C [, Horizontal_Position as N [, Vertical_Position as N ]]]] )
                  ...and "Childform" argument below can then be picked using a msgbox or dropdown similar to Alpha's built in function helpers. Function below is just skeleton code for this example....

                  Code:
                  FUNCTION AddChild as C (Childform as C)
                  addin.function_argument_help=(Call function to list all forms in app for my help when implementing function in my app)
                  
                  DIM formptr as P
                  formptr = FORM.LOAD(childform, "dialog","","Center","Center")
                  formptr.new_record()
                  formptr.show()
                  
                  
                  END FUNCTION
                  Thoughts?

                  Thanks...

                  JK

                  Comment


                    #10
                    Re: Can enum be used in a UDF for a function parameter?

                    Hi Jeff,

                    I had a page or reply and then Mozilla crashed and lost it! :(

                    Gist of it as I have to leave---check out the prior thread given as reference earlier. I believe I gave a list by Selwyn of the addin.function_argument_help Alpha uses and you can use those as guides to build your own.

                    addin.function_argument_help is used to give a function's arguments more "functionality" such as dropdowns, lists, values, etc.. it can be anything that you can add in a single line via xbasic really.

                    Better to use built-in Alpha methods as less headaches overall. addin.function_argument_help has to be run at least once prior to function being used in order for it to work.

                    You will find that mods made to a function that includes the addin.function_argument_help inside it will not show the mods made until you exit and reenter the database.

                    had more but gotta go!!!! If any questions just holler as you know I will be checking back in! :)
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment

                    Working...
                    X