Recent

Author Topic: If then else  (Read 12725 times)

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: If then else
« Reply #30 on: September 26, 2017, 01:21:27 pm »
Quote
In this case the color always stays at default
Yes, of course, you set the Color to clDefault outside the CASE statement and at the end of the procedure, so the last thing the procedure does is setting the DEFAULT color....
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: If then else
« Reply #31 on: September 26, 2017, 07:54:40 pm »
"Because it is too easy" does not describes problems that "giving an answer" may cause for someone. It also does not describes advantages it may have, depending on the circuntances. So here we go:

Programming, as an educational endeavor, as a tech enterprise, have some pretty complicated challenges. If you are in a tech company, or is an independent tech professional, you will have competitive advantage if you live in a workplace (or open community) that promotes autonomy to solve problems, to research about themand to communicate efficiently in order to colaborate around them. It is not that hard to recognize that both autonomy and colaboration are imperative for the enterprise success.

But how to colaborate efficiently and also promote autonomy (auto-regulation, auto-management, as you wish), speacially in open communities? Foolish joking, unjustified public embarrassment, bullying and so on are not the answer.

Should you copy-paste an answer from this very forum?

It depends on you (and your environment). If you choose to copy-paste, you should also have a proper understanding of what you are doing, legally, logically, ethically and so on. You should be honest with yourself by linking (in the paste location) to the post from where you copy, even if you have adapted the code. You should understand the code before running it, for the sake of your own safety and productivity. Many things can generate unexpected addiction that, in turn, will block your motivation. Disoriented copy-paste is one of them.

Should you answer a question by giving the answer?

It depends on the question. For this especific question, I can't think of a single reason to not give the answer. I would do it this way:

Note that in pascal the assigment operator is := and the equal operator is =. Please, try again with this information. Also, for more info about pascal operators see:

Assigment operator
https://www.freepascal.org/docs-html/ref/refsu52.html#x157-17900013.1.1

Equal operator
https://www.freepascal.org/docs-html/ref/refsu50.html#x153-17500012.8.6

How to read sintax diagrams?
https://www.freepascal.org/docs-html/ref/refli5.html#x6-5000

« Last Edit: September 26, 2017, 08:03:25 pm by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: If then else
« Reply #32 on: September 27, 2017, 09:46:42 am »
@cpicanco: Yes it does. If you do programming in a specific language, you are supposed to know exactly what you do when you write a statement. Even beginners. When I start with a new language (it wasn't all that long ago that I started with Pascal relatively speaking) I usually get a book or reference guide showing me the basics. The asignment and equal operators in Pascal are SO fundamental, it is one of the first things if not THE first thing I learned. And coming from BASIC-like languages I had to make the same mistake several times before it really sank in.

Assignment is not the same as comparison and Pascal forces the programmer to know the difference, which I believe is a great thing.

This topic was essentially unnecessary IF the OP would have taken the time to figure out the basics. Instead he jumped at the forum to get a quick answer. THAT is too easy. BTW in my comment I literally gave the answer, but I left it to the programmer to see the logic and correct the code himself.
keep it simple

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: If then else
« Reply #33 on: September 27, 2017, 10:06:41 am »
@ molly and everyone
I did get it.  Even before I saw the sample code posted here.

It was right there in front of me, I just couldn't see it.
Yes, i was aware that you already had your face-palm moment before i even wrote that post.

fwiw: I was not trying to bash your silence there. Since some people seem stuck in twitter mode, i summarized the thread. Harsh words seems required to get the message across (in a tweet).

Quote
Just in case you were interested this is what gave me the clue as to what I was doing wrong.
"Colonize (add a colon to) assignments and decolonize (remove colon from) expressions."
tbh i thought the first clue from Bazzao was a much better one, but in the end it only matters what works for you (e.g. if it can work as a reminder for you)

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: If then else
« Reply #34 on: September 27, 2017, 10:18:36 pm »
Quote
When I start with a new language (it wasn't all that long ago that I started with Pascal relatively speaking) I usually get a book or reference guide showing me the basics

Good for you. Are you assuming that OP knows how to access and how to find these resources?

Quote
And coming from BASIC-like languages I had to make the same mistake several times before it really sank in.

You should not assume that because it was hard for you that it must be for others too.

Quote
This topic was essentially unnecessary IF the OP would have taken the time to figure out the basics. Instead he jumped at the forum to get a quick answer.

You were assuming OP had a bad attitude and you are assuming that he thought this forum is a way to get a "quick answer". Sorry dude, I think you are assuming too much.
 
Be mindful and excellent with each other.
https://github.com/cpicanco/

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: If then else
« Reply #35 on: September 28, 2017, 09:52:20 am »
Quote
When I start with a new language (it wasn't all that long ago that I started with Pascal relatively speaking) I usually get a book or reference guide showing me the basics

Good for you. Are you assuming that OP knows how to access and how to find these resources?

Quote
And coming from BASIC-like languages I had to make the same mistake several times before it really sank in.

You should not assume that because it was hard for you that it must be for others too.

Quote
This topic was essentially unnecessary IF the OP would have taken the time to figure out the basics. Instead he jumped at the forum to get a quick answer.

You were assuming OP had a bad attitude and you are assuming that he thought this forum is a way to get a "quick answer". Sorry dude, I think you are assuming too much.
Yes dude, if one knows how to find its way to the forum, then assuming that one knows how to use google as a start, isn't being unrealistic.

But it is nice mirroring you display here assuming "it was hard for me". No it wasn't. I just gave an example that applies to many if not most coming from another programming language.

I also did not "assume" the OP had a bad attitude. Asking for a quick answer isn't exactly something I would call bad. What I was trying to say is that I perfectly understand why a copy-paste answer wasn't given right away.

It looks like you're exaggerating here for whatever reason and you like to reflect things back at me while it is not at all about me. I was giving some examples in light of the OP having programming experience, according to his own words.

But thanks a lot for your opinion, dude. Now I end this conversation because it is going way off topic.

Note: Edited.
« Last Edit: September 28, 2017, 10:22:20 am by munair »
keep it simple

Yukiko

  • Jr. Member
  • **
  • Posts: 55
Re: If then else
« Reply #36 on: October 07, 2017, 02:01:22 am »
Let me start my comment on this thread by saying that I have generally found the Lazarus/Free Pascal community very friendly and helpful.

Though my initial experience with Pascal was a very long time ago, 1980s for anyone who cares. I came to discover the Lazarus project 9 years ago and I believe back then some many people must have helped me right here on the forums because I started a project then and for some unexplained reason abandoned it, absolutely forgot I had ever started it then rediscovered it 9 years later, and pardon the word play here, resurrected it (those who know the Biblical story of Lazarus will get it  :D ), and I can't believe I had written the code. Evidence that this community obviously helped me because I am a mediocre programmer at best.

On the subject of a quick answer I'd say yes feel free to give one but along with that either give some explanation to help educate the person or post links for further reading. How you phrase the "quick answer" can provoke a learning experience in itself. The person who gave the answer
Quote
Colonize (add a colon to) assignments and decolonize (remove colon from) expressions.
didn't actually give what I would call a quick answer. I apologize that I don't remember your name. A quick answer in my opinion would have been to post corrected syntax of the 'if' statements.

I don't have a problem with "quick answers" generally. Sometimes someone is trying to get something to work in the moment and they may not have time to take a course in object Pascal. If the same person keeps coming back with "pre-school" programming questions then it's time to point them to online tutorials such as Lut has written. Many of us are not working in an "enterprise" or work related programming job. Some are just needing to explore our ability to create something and others like myself are working as a developer for free on an open source project and don't have the money or time to learn all the ins and outs of object Pascal. So sometimes a quick answer is enough.

On the subject of documentation I have found the CHMs and PDFs to be both helpful and frustrating. The CHMs are particularly frustrating because there are many "broken links" that give the error can't find page or something similar. I have found the Free Pascal wiki to be the most helpful place to go to find help on my own though many of the concepts that it is assumed I am supposed to understand are still above my level. Honestly, as someone else pointed out, a search engine is often very helpful, much more so than the included documentation with Lazarus.

Now to my final comment. Yeah I know you're all sighing with relief. :)
I appreciate the help I have received here. I hate to see the answer to a simple question turn into such a contentious thing. Both sides were right. You should learn the basics of the syntax of the language you are programming in and sometimes a quick answer is all that is needed. I can't tell you how many times I have sat and spent sometimes hours looking at some piece of code I had written trying to figure out why it isn't working only to have someone look over my shoulder and say "you're using a greater than when you need a less than equals operator" or some such thing. Of course I knew that but I was not seeing the "trees for the forest" to twist a metaphor. The code had gotten in the way and I totally overlooked the detail.

Thanks again for all the help I have received over the years.

 

TinyPortal © 2005-2018