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

"Position" function?

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

    "Position" function?

    Maybe chalk this up to blindness or stupidity, but is there a "Position" or "Search" function in A5?

    By this, I mean a function which will search a string for a specified string and return the position at which it first occurs. I know that the contains function searches, but it returns a logical value, not the position.

    While this will be a fairly easy xbasic function to add, it seems like it should be a standard feature.

    #2
    RE:

    position at which it first occurs
    There can be only one.

    Comment


      #3
      RE:

      Roy,

      The new Functions and Expressions book explains how the functions work. Finding the right one when you don't know what you're looking for can be problematic.

      Try the User's Guide instead. There's an overview with a listing by 'type' beginning at about pg 301.

      -- tom

      Comment


        #4
        RE:

        Roy

        page 14 of the Expression_Functions_Reference manual.

        The function is:

        at(SearchString,CharacterString,[Number])
        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


          #5
          RE:

          Thanks Al. I guess I was trying to be too cute. Should I have posted:

          position at(SearchString,CharacterString,[Number]) which it first occurs

          ?
          There can be only one.

          Comment


            #6
            Position Function Unbound

            Well, I'll call it blindness then. :)

            In the interim, I wrote the position function from hell (I almost called if pfh ;)

            It accepts 5 arguments:
            LOOKIN - what to look in
            LOOKFOR - what to look for
            NTHOCCUR - which occurence to look for
            STARTFROM - start looking from L/R
            MEASUREFROM - measure position from L/R

            Let the parsing begin! (and the code improvements, no doubt)

            'Date Created: 02-Apr-2003 10:41:16 AM
            'Last Updated: 02-Apr-2003 11:09:46 AM
            'Created By : Roy Irby
            'Updated By :
            'Returns the of the Nth occurance of a string (LOOKFOR) within a string (LOOKIN)
            'starting from left or right (STARTFROM) and counted from left or right (MEASUREFROM)
            '
            FUNCTION POSFROM AS N (LOOKIN AS C, LOOKFOR AS C, NTHOCCUR AS N, STARTFROM AS C,MEASUREFROM AS C)
            ' first check the passed variables and see if the substring is present at all
            ' if the variables are invalid or the string is not present, skip to the end
            IF (STARTFROM "L" .AND. STARTFROM "R") .or. \
            (MEASUREFROM "L" .and. MEASUREFROM "R") .or. \
            OCCURS(LOOKFOR,LOOKIN)=0 then
            GOTO FOUND
            END IF
            ' setup the looping
            DIM I AS N, NUMFOUND AS N,START AS N, FINISH AS N, STEPBY AS N
            NUMFOUND=0
            POSFROM=0
            IF STARTFROM="L" THEN 'loop forward if STARTFROM = L(eft)
            START=1
            FINISH=LEN(LOOKIN)
            STEPBY=1
            ELSE
            START=LEN(LOOKIN) 'loop backward if STARTFROM = R(ight)
            FINISH=1
            STEPBY=-1
            END IF
            ' commence with the looping
            FOR I= START TO FINISH STEP STEPBY
            IF SUBSTR(LOOKIN,I,LEN(LOOKFOR))=LOOKFOR THEN
            POSFROM=I
            NUMFOUND=NUMFOUND+1
            IF NUMFOUND=NTHOCCUR THEN
            GOTO FOUND
            END IF
            END IF
            NEXT I
            FOUND:
            IF MEASUREFROM="R" THEN 'compensate if MEASUREFROM = R(ight)
            POSFROM=len(lookin)-POSFROM+1
            END IF
            END FUNCTION

            Comment


              #7
              RE: Position Function Unbound

              Man, how do you get the formating to look right on this board? ;)

              Comment


                #8
                RE:

                Stan

                no problem

                It took me a minute to get what you were driving AT!

                ;-)
                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


                  #9
                  RE: Position Function Unbound

                  'Date Created: 02-Apr-2003 10:41:16 AM
                  'Last Updated: 02-Apr-2003 11:09:46 AM
                  'Created By : Roy Irby
                  'Updated By :
                  'Returns the of the Nth occurance of a string (LOOKFOR) within a string (LOOKIN)
                  'starting from left or right (STARTFROM) and counted from left or right (MEASUREFROM)
                  '
                  FUNCTION POSFROM AS N (LOOKIN AS C, LOOKFOR AS C, NTHOCCUR AS N, STARTFROM AS C,MEASUREFROM AS C)
                  ' first check the passed variables and see if the substring is present at all
                  ' if the variables are invalid or the string is not present, skip to the end
                  IF (STARTFROM "L" .AND. STARTFROM "R") .or. \
                  (MEASUREFROM "L" .and. MEASUREFROM "R") .or. \
                  OCCURS(LOOKFOR,LOOKIN)=0 then
                  &nbsp&nbsp&nbspGOTO FOUND
                  END IF
                  ' setup the looping
                  DIM I AS N, NUMFOUND AS N,START AS N, FINISH AS N, STEPBY AS N
                  NUMFOUND=0
                  POSFROM=0
                  IF STARTFROM="L" THEN 'loop forward if STARTFROM = L(eft)
                  &nbsp&nbsp&nbspSTART=1
                  &nbsp&nbsp&nbspFINISH=LEN(LOOKIN)
                  &nbsp&nbsp&nbspSTEPBY=1
                  ELSE
                  &nbsp&nbsp&nbspSTART=LEN(LOOKIN) 'loop backward if STARTFROM = R(ight)
                  &nbsp&nbsp&nbspFINISH=1
                  &nbsp&nbsp&nbspSTEPBY=-1
                  END IF
                  ' commence with the looping
                  FOR I= START TO FINISH STEP STEPBY
                  IF SUBSTR(LOOKIN,I,LEN(LOOKFOR))=LOOKFOR THEN
                  &nbsp&nbsp&nbspPOSFROM=I
                  &nbsp&nbsp&nbspNUMFOUND=NUMFOUND+1
                  &nbsp&nbsp&nbspIF NUMFOUND=NTHOCCUR THEN
                  &nbsp&nbsp&nbsp&nbsp&nbsp&nbspGOTO FOUND
                  &nbsp&nbsp&nbspEND IF
                  END IF
                  NEXT I
                  FOUND:
                  IF MEASUREFROM="R" THEN 'compensate if MEASUREFROM = R(ight)
                  &nbsp&nbsp&nbspPOSFROM=len(lookin)-POSFROM+1
                  END IF
                  END FUNCTION
                  There can be only one.

                  Comment


                    #10
                    RE: Position Function Unbound

                    tnx Stan!

                    Comment


                      #11
                      RE: Position Function Unbound

                      Stan,

                      Alright, quit showing off. Now if you could mix in a few interesting colors here and there, and maybe bold face the looping structures...

                      -- tom

                      Comment


                        #12
                        RE: Position Function Unbound

                        I could, but Cal could do it better.

                        Have a good time at the conference. Try to keep Hanigsberg out of trouble this year.
                        There can be only one.

                        Comment


                          #13
                          RE: Position Function Unbound

                          Surround your Xbasic code in "PRE$gt; and "/PRE$gt; HTML tags. That forces your spacing, indentatuiopn and line breaks to be kept.

                          -Lenny

                          Lenny Forziati
                          Vice President, Internet Products and Technical Services
                          Alpha Software Corporation

                          Comment


                            #14
                            RE: Position Function Unbound

                            'Date Created: 02-Apr-2003 10:41:16 AM
                            'Last Updated: 02-Apr-2003 11:09:46 AM
                            'Created By : Roy Irby
                            'Updated By :
                            'Returns the of the Nth occurance of a string (LOOKFOR) within a string (LOOKIN)
                            'starting from left or right (STARTFROM) and counted from left or right (MEASUREFROM)
                            '
                            FUNCTION POSFROM AS N (LOOKIN AS C, LOOKFOR AS C, NTHOCCUR AS N, STARTFROM AS C,MEASUREFROM AS C)
                            ' first check the passed variables and see if the substring is present at all
                            ' if the variables are invalid or the string is not present, skip to the end
                            IF (STARTFROM "" "L" .AND. STARTFROM "" "R") .or. \
                            (MEASUREFROM "" "L" .and. MEASUREFROM "" "R") .or. \
                            OCCURS(LOOKFOR,LOOKIN)=0 then
                            GOTO FOUND
                            END IF
                            ' setup the looping
                            DIM I AS N, NUMFOUND AS N,START AS N, FINISH AS N, STEPBY AS N
                            NUMFOUND=0
                            POSFROM=0
                            IF STARTFROM= "L" THEN 'loop forward if STARTFROM = L(eft)
                            START=1
                            FINISH=LEN(LOOKIN)
                            STEPBY=1
                            ELSE
                            START=LEN(LOOKIN) 'loop backward if STARTFROM = R(ight)
                            FINISH=1
                            STEPBY=-1
                            END IF
                            ' commence with the looping
                            FOR I= START TO FINISH STEP STEPBY
                            IF SUBSTR(LOOKIN,I,LEN(LOOKFOR))=LOOKFOR THEN
                            POSFROM=I
                            NUMFOUND=NUMFOUND+1
                            IF NUMFOUND=NTHOCCUR THEN
                            GOTO FOUND
                            END IF
                            END IF
                            NEXT I
                            FOUND:
                            IF MEASUREFROM= "R" THEN 'compensate if MEASUREFROM = R(ight)
                            POSFROM=len(lookin)-POSFROM+1
                            END IF
                            END FUNCTION
                            There can be only one.

                            Comment


                              #15
                              RE: Position Function Unbound

                              Very pretty Stan. ;)

                              Comment

                              Working...
                              X