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

Problem with simple "IF" statement cause

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

    Problem with simple "IF" statement cause

    I have a fatal error occurring in a simple "IF" statement in a report every time I run the report. The IF statement is for a calculated variable that takes this form:

    MyCalc = if(calc1""calc2,initialvalue,MyCalc)

    Which is to say that I want the MyCalc calculated variable to retain its current setting until calc1 is not equal to calc2 when it will be assigned an initial value.

    The problem I have is that when I run the report A5 immediately terminates - no error message of warning of any kind, it just immediately terminates.

    I have tried rearranging the IF statement but with no effect, the same problem recurs.

    Is there a work-around available? I just want the calculated variable to retain its current setting until calc1 is equal to calc2. A simple enough requirement but seemingly impossible for me to implement.

    (I have attached a screen dump of the detail if anyone wants to see more).

    #2
    RE: Problem with simple

    try creating another calculated field "calc3" equalt to whatever and then
    MyCalc = if(calc1""calc2,initialvalue,calc3)

    Comment


      #3
      RE: Problem with simple

      OK, thanks. I will try this out.

      Comment


        #4
        RE: Problem with simple

        brett, if that doesn't work try reframing the expression without using any other calc fields to do so.

        -- t

        Comment


          #5
          RE: Problem with simple

          Thanks for the suggestion, Tom, but I don't think that will be possible. This is a really complex report I am converting from a ten year old Alpha Four DOS-based application. The original report could not be done in A4 so I had previously done it using a third party report writer, R&R. So far I am not having a lot of joy re-doing the report in A5 either. I have just decided to scrap three day's work on the report and start again and see how I get on this time.

          Comment


            #6
            RE: Problem with simple

            Brett:
            There is nothing simple about your "If" statment! I hate to break the news to you, but you simply can not make the left side of the equation dependant on the right side of the equation which is dependant on the left side of the equation...!!! you see where a5 is having trouble! you threw alpha in a never-ending "vicious cycle" hence the fatal error. Matter of fact, this is not just alpha's problem: if you try to do that in Excel or Lotus 123 you will not even be able to enter the function in the first place!
            I read John's suggestion, but I have a feeling it will give you the same erro since you are doing the same "inter-dependency" except this time with a third party!
            So now what? you could do it with a "simple" xbasic:
            if calc1""calc2
            mycalc=initialvalue
            end if

            Comment


              #7
              RE: Problem with simple

              Yes, I see your point. I guess I am used to working with another product that *does* allow this syntax whereas A5 appears to accept it and then fall over with an internal error.

              What I want to do is have a calculated field in a report with the following type of logic:

              Dim A as C
              IF A = "ABC" then
              A = A + "XYZ"
              END IF

              That is to say, no ELSE statement. But the A5 IF statement syntax in the reporting module does not allow either of the following 2 options that would give me this equivalent result:

              A = IF(A="ABC",A+"XYZ",A) i.e. leave the value of A untouched if it is equal to "ABC"

              or

              A = IF(A="ABC",A+"XYZ") i.e. leave out the ELSE branch

              So I appear to be stuck and with no easy work around. Am I missing something? Surely there must be syntax in the A5 reporting module that would allow me to achieve this result.

              Comment


                #8
                RE: Problem with simple

                Brett:
                No, you are not stuck. The two approaches appear identical, like twin isiters, but in fact they are totally different:
                if you enter an equation like this: A = A + "XYZ" in a function (functions are equations, xbasic is your gofer!, functions work according to the laws of math, xbasic will do whatever you tell it do! it's a subtle difference and that seems to cause your frustration).

                Take Look at this equation for a second and think:
                A=A+"XYZ" !!

                Since when 1 equals 1+2 ?
                Go tell that to the marines! If that's possible you my friend have made the discovery of the melinium and you could be the richest man ever lived because you could make a dollar equals a dollar and then some! Only Jesus broke this laws when he broke the bread and mutliplied it, but I do not know if Brett could do it!

                But with xbasic, your gofer, you tell xbasic: go change A from A to A+"XYZ". I I captain! no problem. But when you put that in equation, alpha is spinning arounfd and around trying to figure out how the heck 1=1+2!
                What you had was an equation from out of this world! does not obey the laws of math! I simply suggested that you change it from an equation (stiff with no sense of humor)to your obdient servant xbasic! When you tell xbasic A=A+"XYZ" you are not telling it that A does equal A+"XYZ" you are telling it GO CHANGE A to A+"XYZ". Can you see the subtle difference!

                Gabe

                Comment


                  #9
                  RE: Problem with simple

                  Here the "=" sign is an operator as commonly used in computer langages: the statement A = A + 1 is an instruction to the computer to take the contents of the variable A, add 1 to it and stick the result back in A. It's not a mathematical equation. But I guess I am stuck with some idiosynchrasies (or problems) that I will have to put up with, I can't see the problem in A5 being fixed so I will have to find a way around it. I was hoping not to have to resort to Xbasic to do such a simple thing, but I may have no other easier option.
                  Thanks for your help, Gabriel.

                  Comment


                    #10
                    RE: Problem with simple

                    Brett,

                    If MyCalc was a table field your approach would be fine.

                    But...

                    as Gabe correctly notes...

                    you're using the calc field MyCalc to define the calc field MyCalc. This isn't permitted in any of the coding languages I've ever used.

                    An easy fix is to compute the alternative value ahead of time, store it in a variable, and use the variable to supply the value to the calc.

                    if( A "" B , New Value, Alternative Value )

                    A further caution: if this a numeric comparison beware of rounding differences that could cause inequality when you don't want it.

                    -- t

                    Comment


                      #11
                      RE: Problem with simple

                      Our experiences must differ because I have found the reverse to me true. For example, defining MyCalc as:

                      if( A "" B , New Value, MyCalc )

                      ... is valid syntax. It works in the DBF report writers I have used, including R&R Report Writer. But there is a trick entailed. The definition must be entered initially as:

                      if( A "" B , New Value, Alternative Value ) ...A

                      This definition must be saved, only then can it be altered to:

                      if( A "" B , New Value, MyCalc ) ...B

                      That is to say the entry for the definition for MyCalc must be present before MyCalc can be used as a parameter in it's own definition. Which sort of makes sense.

                      You should try this little trick in some of the "coding languages" you mention.

                      Now, lets try this same trick with the A5 report writer.

                      Entering an initial definition for MyCalc into A5 as in B above gives a syntax error. But when entered as per A, saved and then modified to B, A5 accepts it as valid syntax!!!

                      And now when I try and run my report containing this definition for MyCalc, A5 crashes in flames. Clearly it shouldn't do so but it does.

                      So where to now? IMHO syntax B is correct and should be accepted by A5 and produce the correct result. The correct result is as per the following code:

                      if A""B then
                      MyCalc = New Value
                      end if

                      That is to say if A is equal to B the value of MyCalc retains its present value.

                      This is a perfectly legitimate logical outcome that is not currently supported by the A5 report writer using this form of the IF statement. In my view it is a serious omission that should be corrected.

                      I am quite prepared to make a submission to the good folk at Alpha Software to this effect if I felt that I would be listened to.

                      Comments welcome.

                      Comment


                        #12
                        RE: Problem with simple

                        Yes, our experiences differ. Good luck with your project.

                        -- t

                        Comment

                        Working...
                        X