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

User definied function, "not found"

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

    User definied function, "not found"

    I'm having some problems with a user defined function. I have on onPush which calls a function, which in turn calls another function:

    Code:
    tmp = address_format("zip", get_web_shopper.zip)
    This line triggers a "function not recognized" error. A5 does recognize address_format(), though:

    Code:
    ?:a5.udf_enum()
    = word_split@c:\local\data base\data base.alb
    new_mktname_from_shopper@c:\local\data base\data base.alb
    new_cusfil_from_shopper@c:\local\data base\data base.alb
    get_web_shopper@c:\local\data base\data base.alb
    get_citystate@c:\local\data base\data base.alb
    get_adodb_conn@c:\local\data base\data base.alb
    address_format@c:\local\data base\data base.alb
    If I open the function, save it, and exit, the code will execute with no errors.

    I'm assuming this doesn't work because there are two functions defined in one function file. However, address_format() is the initial function, and starts on the very first line. I thought I read that multiple functions per function file were allowed, but only the first would be global.

    Does anyone have a suggestion to fix this? I'd rather not split the two functions up unless it's necessary (which seems to be the case).
    Last edited by abackstrom; 10-05-2005, 01:00 PM. Reason: Terminology error.
    Adam Backstrom <[email protected]>

    #2
    This function

    Code:
    FUNCTION stacked AS L (mess1 AS C )
    	ui_msg_box("Testing",mess1)
    	second("Second udf - internal")
    END FUNCTION
    FUNCTION second AS L (mess2 AS C )
    	ui_msg_box("Testing",mess2)
    END FUNCTION
    operates from a button push when mess1 is defined.

    I'd have to see more about how you are doing things to offer any suggestions.
    There can be only one.

    Comment


      #3
      Stan,

      What other information would be helpful?
      Adam Backstrom <[email protected]>

      Comment


        #4
        Stan's suggestion is pretty much the workaround.

        I use a dispatch script with a select/case statement as my first function to call other functions in the same file.

        Obviously, Alpha's preference is that you create individual global functions, but I find that especially when doing co-op development, it's handy to be able to do this to share variables among functions and avoid clutter in the code list.

        Code:
        FUNCTION dispatch (cAction as C)
        select
          case cAction = "func1"
            func1(blah)
          case cAction = "func2"
            func2(foo)
        end select
        END FUNCTION
        
        FUNCTION func1
        END FUNCTION
        
        FUNCTION func2
        END FUNCTION
        You could also use EVALUATE_TEMPLATE() instead of the select/case statement, depending on your needs.
        Last edited by Rick Gerlach; 10-05-2005, 01:18 PM.

        Comment


          #5
          I'm not clear what is meant by
          address_format("zip", get_web_shopper.zip)
          Is address_format()'s second parameter the name of the second called function? If so I don't see "get_web_shopper.zip" in the enum list I see "get_web_shopper".


          If your address_format() function is defined something like

          Code:
          function address_format as C (string as C, func as f)
              statements here
          address_format = some result
          end function
          then I am not understanding the purpose of the ".zip" ending on the parameter.
          There can be only one.

          Comment


            #6
            Stan,

            Here are the applicable parts of that script:

            Code:
            FUNCTION get_web_shopper AS P ( registration_num = -1 )
            	[I]-snip-[/I]
            	get_web_shopper.zip = fld.item("zip").value
            	[I]-snip-[/I]
            	
            	' pass the values through formatting functions
            	DIM tmp AS P
            	tmp = address_format("zip", get_web_shopper.zip)
            	if .not. isnull(tmp.zip4) then
            		trace.writeln("we had a zip4: " + tmp.zip + "{-}" + tmp.zip4)
            		get_web_shopper.zip = tmp.zip
            		get_web_shopper.zip4 = tmp.zip4
            	end if
                    [I]-snip-[/I]
            END FUNCTION
            Here is the full code in the address_format() function:

            Code:
            FUNCTION address_format AS A (type AS C, user_value AS A)
            	select
            		case type = "zip"
            			address_format = address_format_zip(user_value)
            	end select
            END FUNCTION
            FUNCTION address_format_zip AS P (user_zip AS C)
            	DIM afp AS P
            	DIM afp.zip AS C
            	DIM afp.zip4 AS C
            	
            	user_zip = alltrim(user_zip)
            	
            	' do we have zip+4?
            	if substr(user_zip, 6, 1) = "-" then
            		afp.zip  = substr(user_zip, 1, 5)
            		afp.zip4 = substr(user_zip, 7)
            		address_format_zip = afp
            		
            		return
            	end if
            	
            	' no, we just have a 5-digit zip (or international zip)
            	afp.zip = user_zip
            	afp.zip4 = ""
            	
            	' return the afp value
            	address_format_zip = afp
            end function
            So, get_web_shopper() calls address_format(). The latter function takes two arguments, in this case two character strings: the first, the type of formatting that should take place, and the second, the string to be formatted. (get_web_shopper.zip is a string value.)

            If I remove address_format_zip() and all references from the address_format() function, the script runs with no problems.
            Adam Backstrom <[email protected]>

            Comment


              #7
              I believe you are correct in that when address_format = address_format_zip(user_value) is executed, it fails because there is no global udf address_format_zip() and it is not being recognized as a local function.

              Sorry I can't think of anything that will help here.
              There can be only one.

              Comment


                #8
                Then again...

                wouldn't this work (though I do like the modularity of your original)

                Code:
                FUNCTION address_format AS A (type AS C, user_value AS A)
                	select
                		case type = "zip"
                		DIM afp AS P
                		DIM afp.zip AS C
                		DIM afp.zip4 AS C
                	
                		user_value = alltrim(user_value)
                	
                		' do we have zip+4?
                		if substr(user_value, 6, 1) = "-" then
                			afp.zip  = substr(user_value, 1, 5)
                			afp.zip4 = substr(user_value, 7)
                		else
                		' no, we just have a 5-digit zip (or international zip)
                			afp.zip = user_value
                			afp.zip4 = ""
                		end if
                		
                		' return the afp value
                		address_format = afp
                		
                '		case type= something else
                '			statements
                				
                		end select
                END FUNCTION
                There can be only one.

                Comment


                  #9
                  Stan,

                  I've done a bit more testing and narrowed this down some. Here is your previous block of code:
                  Code:
                  FUNCTION stacked AS L (mess1 AS C )
                  	ui_msg_box("Testing",mess1)
                  	second("Second udf - internal")
                  END FUNCTION
                  FUNCTION second AS L (mess2 AS C )
                  	ui_msg_box("Testing",mess2)
                  END FUNCTION
                  This block works for me if I call stacked() from an onPush. Now, try this code:
                  Code:
                  FUNCTION stacked AS L (mess1 AS C )
                  	ui_msg_box("Testing",mess1)
                  	[B]stacked_internal[/B]("Second udf - internal")
                  END FUNCTION
                  FUNCTION [B]stacked_internal[/B] AS L (mess2 AS C )
                  	ui_msg_box("Testing",mess2)
                  END FUNCTION
                  Save the script, re-open the database, and hit the button. Does this flag a "not recognized" error for you? It does for me. Open the script, save it, then press the button again. (Don't re-open the database this time.) The error should go away.

                  Are you able to reproduce this bug? It seems like the engine is getting confused, some sort of function naming conflict is taking place. The conflict goes away if the script is resaved.
                  Adam Backstrom <[email protected]>

                  Comment


                    #10
                    Behavior observed as noted.

                    May be a long name problem.

                    Stacked and stacked_internal

                    don't differ until the ninth position.

                    address_format and address_format_zip

                    until the sixteenth.
                    There can be only one.

                    Comment

                    Working...
                    X