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

Array pointer in function parameter

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

    Array pointer in function parameter

    This works:

    Code:
    FUNCTION zzz AS V (cList="" as C)
    	msgbox("C")
    End FUNCTION
    
    
    zzz()

    But how do I get this to work?
    Code:
    FUNCTION zzz AS V (pList as P)
    	msgbox("P")
    End FUNCTION
    
    
    zzz()
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com



    #2
    Re: Array pointer in function parameter

    Originally posted by Peter.Greulich View Post
    This works:

    Code:
    FUNCTION zzz AS V (cList="" as C)
    	msgbox("C")
    End FUNCTION
    
    
    zzz()

    But how do I get this to work?
    Code:
    FUNCTION zzz AS V (pList as P)
    	msgbox("P")
    End FUNCTION
    
    
    zzz()
    See if null_value() works for you: http://documentation.alphasoftware.c...0Variables.xml

    Code:
    FUNCTION zzz AS  (pList = null_value() as P)
    	msgbox("P")
    end FUNCTION
    
    zzz()
    Sarah Mitchell
    Director of Customer Success | [URL="https://www.alphasoftware.com"]Alpha Software Corporation[/URL]
    [B]Get in the know! [/B] Join us for our Weekly Webinars: [URL="https://www.alphasoftware.com/weekly-transform-tuesday-webinar"]TransForm Tuesday[/URL] and [URL="https://www.alphasoftware.com/weekly-alpha-anywhere-overview-webinar"]Wednesday's Alpha Anywhere Demo and Q&A[/URL]
    Connect with us: [URL="https://www.instagram.com/alpha_software_corp/"]Instagram[/URL] | [URL="https://twitter.com/AlphaSoftware"]Twitter[/URL] | [URL="https://www.facebook.com/AlphaSoftware/"]Facebook[/URL] | [URL="https://www.linkedin.com/company/alpha-software"]LinkedIn[/URL] | [URL="https://www.youtube.com/user/AlphaSoftwareInc"]YouTube[/URL]

    Comment


      #3
      Re: Array pointer in function parameter

      null_value() that's what I was looking for.

      I had tried null and of course it didn't work.

      Thanks Sarah
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        Re: Array pointer in function parameter

        Actually that doesn't work Sarah.

        This errors out:

        Code:
        FUNCTION zzz AS V (pList = null_value() as P)
        	Dim pList.Test as C
        	
        end FUNCTION
        
        zzz()
        Peter
        AlphaBase Solutions, LLC

        [email protected]
        https://www.alphabasesolutions.com


        Comment


          #5
          Re: Array pointer in function parameter

          This works, but I'm not sure I like it:

          Code:
          FUNCTION zzz AS V (pList = null_value() as P)
          	if typeof(pList) = "Z"
          		Delete pList
          		Dim pList as P
          		Dim pList.Test as C = "test"
          	end if
          	
          	msgbox(pList.Test)
          	
          end FUNCTION
          
          zzz()
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            Re: Array pointer in function parameter

            Originally posted by Peter.Greulich View Post
            Actually that doesn't work Sarah.

            This errors out:

            Code:
            FUNCTION zzz AS V (pList = null_value() as P)
            	Dim pList.Test as C
            	
            end FUNCTION
            
            zzz()
            If nothing is passed in, the type is 'Z', as you state in the second post. You'll have to check the type if you want to alter the parameter.

            Instead of trying to use the parameter, use a local variable instead. EG:
            Code:
            FUNCTION zzz AS V (pL = null_value() as P)
            	dim pList as p
            	if (typeof(pL) = "P") then
            		pList = pL
            	end if
            	
            	pList.Test = "test"
            
            	msgbox(pList.Test)
            	
            end FUNCTION
            
            zzz()
            Sarah Mitchell
            Director of Customer Success | [URL="https://www.alphasoftware.com"]Alpha Software Corporation[/URL]
            [B]Get in the know! [/B] Join us for our Weekly Webinars: [URL="https://www.alphasoftware.com/weekly-transform-tuesday-webinar"]TransForm Tuesday[/URL] and [URL="https://www.alphasoftware.com/weekly-alpha-anywhere-overview-webinar"]Wednesday's Alpha Anywhere Demo and Q&A[/URL]
            Connect with us: [URL="https://www.instagram.com/alpha_software_corp/"]Instagram[/URL] | [URL="https://twitter.com/AlphaSoftware"]Twitter[/URL] | [URL="https://www.facebook.com/AlphaSoftware/"]Facebook[/URL] | [URL="https://www.linkedin.com/company/alpha-software"]LinkedIn[/URL] | [URL="https://www.youtube.com/user/AlphaSoftwareInc"]YouTube[/URL]

            Comment


              #7
              Re: Array pointer in function parameter

              This works if that is what you wanted:
              FUNCTION zzz AS C (pList AS P = null_value() )
              dim shared pList.test as c
              pList.Test = "This is a test"
              zzz = pList.Test
              END FUNCTION
              ?zzz()
              ="This is a test"
              Robin

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

              Comment


                #8
                Re: Array pointer in function parameter

                No Mo. Shared var = bad!

                I'll use Sarah's suggestion. That's better.
                Peter
                AlphaBase Solutions, LLC

                [email protected]
                https://www.alphabasesolutions.com


                Comment


                  #9
                  Re: Array pointer in function parameter

                  http://wiki.alphasoftware.com/~alphafiv/Arrays
                  take a look at this page and this paragraph:
                  Passing Arrays to Functions
                  When you pass an array to a function, the receiving function defines the argument as a pointer.
                  Dim a[5] as C
                  a[1] = "a value"
                  my_function(a)
                  function my_function as V (arr as P)
                  ui_msg_box("Array Value", arr[1])
                  end function
                  ran a quick test and it works as described,
                  at least in the earlier posts i do not see you passing any array to the function.
                  Last edited by GGandhi; 05-26-2016, 07:33 PM.
                  thanks for reading

                  gandhi

                  version 11 3381 - 4096
                  mysql backend
                  http://www.alphawebprogramming.blogspot.com
                  [email protected]
                  Skype:[email protected]
                  1 914 924 5171

                  Comment


                    #10
                    Re: Array pointer in function parameter

                    In you initial post you say you wrote a function:
                    Code:
                    FUNCTION zzz AS V (cList="" as C)
                    	msgbox("C")
                    End FUNCTION
                    zzz()
                    And you say it works.
                    "It does", really shouldn't but it does for the following reason:
                    The funtion has a C Parameter and you defaulted it to blank, actually null. So when you type zzz() in the IW, "It works".
                    When you wrote zzz() in the IW, you did not supply a value for that parameter. But since the function defaults that parameter to null, "It works", unwittingly, even though you did not supply a parameter, which amounted to the same thing as supplying a null.

                    But when you tried to do the same thing with a P parameter, it threw an error.
                    It did. BECAUSE YOU DID NOT SUPPLY A VALUE FOR THE PARAMETER. YOU JUST TYPED ZZZ() IN THE IW.
                    That wouldn't work unless you supply a value for that parameter OR you make this parameter optional. You did neither.

                    The function should have been written as follows:
                    Code:
                    FUNCTION zzz AS P (pList as P)
                    	zzz=plist
                    End FUNCTION
                    Now, in the IW try this:
                    Code:
                    dim mylist as p
                    dim mylist.name as c
                    dim mylist.age as n
                    mylist.name="Joe"
                    mylist.age=35
                    ?zzz(mylist)
                    = age = 35
                    name = "Joe"
                    If you want the function as V instead of P, you could do that too. It will run as a script and acquires the values of mylist. It's up to you what you want to do with these values later. And you could write the function as follows:
                    Code:
                    FUNCTION zzz AS V (pList as P)
                    	msgbox("function ran")
                    End FUNCTION
                    Now run the function from the IW:
                    Code:
                    dim mylist as p
                    dim mylist.name as c
                    dim mylist.age as n
                    mylist.name="Joe"
                    mylist.age=35
                    ?zzz(mylist)
                    = <Has no sub-properties>
                    The msg box will pop up but you will get the error <Has no sub-properties> because it doesn't. That error should not hamper what you are doing ( I don't think, but again I never write functions this way so I can't swear to it) if you acquire the values of plist and process them whichever way you want but you have to remember those values are local variables and you have to get a pointer to those local variables.
                    Alternatively, you could write it as V with no parameters since your objective would be to run it as an encapsulated script.
                    It's easier and much better to do it as a P instead of a V function.

                    Comment

                    Working...
                    X