Jump to content

Wiki Challenge Part 2


czardas
 Share

Wiki Challenge II  

21 members have voted

  1. 1. Which of the examples (in posts 2 and 3) do you think is most suited for a beginner?

    • Example 1
      0
    • Example 2
    • Example 3
    • Example 4
    • Example 5
      0
    • Example 6


Recommended Posts

Normally when you want to add two (or more) numbers together you use the plus(+) sign between them.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

from the helpfile

4096+4 (or 4100)

so from a beginner perspective im just going going to assume 4100 by adding them together

After some messing about i spotted a thread somewhere else that had BitOR in it, so i ended up with this which appears to work

MsgBox(BitOR($MB_YESNO,$MB_ICONWARNING), 'title Goes Here','Msg Goes Here')

Your never going to cover everyone of course but a line that states

To join Constant Names instead of numbers use  

MsgBox(BitOR($MB_YESNO,$MB_ICONWARNING), 'title Goes Here','Msg Goes Here')

isnt going to hurt is it

You get the idea im sure

Edited by Chimaera
Link to comment
Share on other sites

Depends on what you're adding together. If you're just adding simple numbers together, like in the message box example you made, there's really no difference between + and BitOr. If you're adding style numbers together sometimes, not very often, when you do that you're getting a different result when you use + or BitOr().

Most of the time BitOr isn't necessary, but it is considered a good coding practice to get into because even though the chance is low, adding (+) styles together will yield different results than using BitOr, and BitOr's results are usually the correct one in those cases.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It is a difficult balancing act. In truth there should be 100% focus on the purpose of an example. If the example is to demonstrate certain facets of a particular function, minimal additional functions should be included. If the example is to teach a concept to a beginner, then attention to correct coding practices should not be allowed to compromize the main objective by overcomplicating the task at hand. As soon as a level is attained where additional information becomes relevant to the person learning, then it's time remove the armbands, otherwise development grinds to a halt. This is a classic strategy in teaching music and I see no reason why it should be any different with coding.

I do not pertain to understand half of the terms used by Microsoft and I have been thinking about the Hello World example in the wiki article. What is the constant $MB_SYSTEMMODAL doing there? I think it should be removed because it is unnecessarily confusing.


Having said this, I think the wiki page could also benefit from an example of a more advanced nature placed at the end.

Edited by czardas
Link to comment
Share on other sites

Regarding Chimaera's comment about combining named constants - you should generally use BitOR(). One of the ideas behind using named constants is not having to worry about the value of their numeric representation. Adding these constants together defeats that whole objective to a large degree. I would expect there to be some exceptions simply because it's feasible, although it would need to be an arithmetic implementation, which is generally not the case.

Edited by czardas
Link to comment
Share on other sites

Ive tried to not involve myself in this debate but i thought i would mention something that i find as a beginner / medium

Why? We wanted feedback, especially from those who are closer to the beginner side of things.

 

I looked at some of the examples and i cant believe some of them were even submitted for a beginner, geez how difficult they seem... (mainly 2,4 and 5)

I think you need to take a closer look at 5. Perhaps remove the comments, if you really think 1 and 3 are less complex.

I can agree, and i thought so when I did it, that it might be a little too complex, but it isn't in the same league as the first 4 examples. If anything, it just tries to do too much.

 

 

The one problem which makes examples for beginners difficult is the perspective of the writer

Everyone that writes for the helpfile or wherever is in most cases a really good coder but, when you write you will naturally assume that oh they will know that or this without me saying it.

I have noticed as AutoIt has evolved the helpfile has become more techy in the examples. Not that im saying it AutoIt shouldn't evolve it seems from my perspective to be growing into a 'proper' language from what i remember in the beginning when i first started.

Due in part to a fantastic helpfile as well as the work from the devs and jon

But don't assume everybody has evolved along with it, if i had come to AutoIt now i would be really struggling.

I seem to be atm helping less and asking more because its getting more difficult as i find it and as the language changes.

Yes im aware i don't have the drive or inclination to learn every nuance of the language, i use it less than 1% in my daily life, a bit of automation to assist in repetitive tasks that i have to do.

And i would be the first to say im not a coder / programmer. The few things i have created are meaningless to the larger community, but they do what i need which is why there were made.

If this hadn't been a helpfull community i would not have come as far as i have.

So please don't forget the perspective of the beginner is really important.

I'm in agreeance with much of that, and I've said similar things in the past.

I expect that is why we get so many more basic questions now, that should have been solved by the Help file.

It is definitely not as simple and easy to understand as it once was.

You only have to look at the complexity of many scripts in the Examples forum now, to see that things have evolved, and we have more complex type of user here in bigger numbers now, and many of those are involved in aspects of where AutoIt is heading.

It's all to do with push and pull factors.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

To join Constant Names instead of numbers use  
MsgBox(BitOR($MB_YESNO,$MB_ICONWARNING), 'title Goes Here','Msg Goes Here')

I can honestly say, that in all the years I've used AutoIt, I have never used BitOr.

Except perhaps when using someone else's code ... so not often.

Using + has always worked well enough for me.

In many instances, still using v3.3.0.0 (or older) means I'm still mostly using magic numbers for things like MsgBox etc.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

@Chimaera - As I stated earlier though, this was not an easy exercise, to come up with the perfect script to meet all criteria.

All of us probably erred in the favor of something.

I know that with 5, I tried to convey how normal the functions names are and the recognizable use.

I tried hard not to have elements that confused or distracted.

I tried to add variety to appeal to a variety of beginners.

I tried to convey power and simplicity.

Even when it came to using variables, I opted (as I do anyway) for simple straight forward names.

To me, having a letter at the start, would mean nothing to a beginner, and possibly just add to the seeming complexity.

It's not needed, though it might be good coding practice.

Personally I've always got along quite fine without it, and it is only a relatively new phenomenon in the AutoIt world, to insist it should be used, to infer things like integer or binary, etc.

The sort of person, that would need to be concerned with such variable naming, is going to pick that up pretty quick anyway.

That and other things I did, was to show how simple normal looking AutoIt is, almost just an extension to the English language, and not nerdy looking like the huge majority of other programming languages, even many of the similar Basic type ones (i.e. VB and VBScript are nerdy looking).

Like others have implied though, you don't want to just appeal to some numbskull, you want to also appeal to the intelligent user who has shown an interest. They are the ones that will really get the benefit and help keep AutoIt relevant and adapting/growing.

EDIT

I didn't think we should see the Example as a tutorial, or even much of a lesson. Though being a lesson couldn't really be avoided. That meant, that any conceptual stuff (variable naming etc), should really be left out. A beginner's tutorial or the first few lessons, would never cover that sort of stuff anyway, and I saw our Example as being a condensed power version of them.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I don't see magic numbers, or named constants, as really being numbers at all. I see them as a series of True or False values which have been converted from binary to decimal. I like to see the hexadecimal personally because I like to understand the binary. However the down side is that more comments are needed. To me this is a trade-off. I think Azijo once nailed it when he said that a named constant is as meaningless to him as a magic number might be, from his perspective as a native Russian. To me this statement carries some weight.

Edited by czardas
Link to comment
Share on other sites

I can honestly say, that in all the years I've used AutoIt, I have never used BitOr.

Except perhaps when using someone else's code ... so not often.

Using + has always worked well enough for me.

In many instances, still using v3.3.0.0 (or older) means I'm still mostly using magic numbers for things like MsgBox etc.

Im trying to update my stuff as i go along to meet modern autoit, all im saying is a refernce to how to use names would suit better then i dont have to ask

All im saying is it ought to mention join numbers together with a '+' symbol or use BitOR($First Name,N'th Name) to join names

Then i will see that and just crack on rather than complete stop to try and work it out or revert back to numbers, which i wasnt doing right anyway by adding them together in my head and using the total :)

I dont necessarily need to know what BitOR does as long as i know i must use it, for those that have the code hunger they will research, i had a look at the Bit ?? stuff in the helpfile to me it might as well be Japanese

My code has changed a lot since i started mainly thx to guinness and melba and many others who taught me to use functions and tidy it up and leave comments as i forget regularly

I was pleased that the examples were notated which always helps, but i wasnt aware who wrote them

Link to comment
Share on other sites

Chimaera, how can I explain this more simply?

There is a two-way switch which can be either on or off. Next to that switch there is another switch. When a switch is off I indicate that with a zero, and when it is on I use the digit one. We have four possibilities: 00, 01, 10 and 11. Lets imagine that the second switch is turned on. We represent that with 01. Now if someone else comes along to turn on the same switch again, it is nonesense to add 1 and 1 together because the result would be 2, and the binary representation of 2 is 10. That would indicate that the second switch is turned off which is wrong. Using BitOR will return the correct result 01, indicating that the second switch is still on, because nobody ever turned it off.

Also you can never turn the switch off using BitOR, because of how it works: ie. if Jack OR Jill, OR anyone else for that matter, turns on the second switch; then the result is always 01 and not 2, 3, 42 or however many numbers you might add together.

Edited by czardas
Link to comment
Share on other sites

I understand and we dont want to be making AutoIt just for the less gifted like me else it will go nowhere

Here's an example from the current helpfile of what i mean

On the MsgBox page we have the age old battle of magic numbers vs names and yes im in favour of names but i have a mSgBox that requires

$MB_YESNO and $MB_ICONWARNING which is 52 but no where that i can see tells me how to join the names together?

If i try $MB_YESNO & $MB_ICONWARNING it ignores the first one, if i use 52 it works fine..

This is the sort of thing that drives me crazy

So i have to use numbers as i dont know how to join them properly

Surely it should say to join names instead of numbers do this... etc etc so i understand how to achieve it?

$MB_YESNO + $MB_ICONWARNING

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Does the following snippet make any logical sense?

Global $result = 0

For $i = 0 To 1000000
    $result = BitOR($result, $i)
    
    If $result = $i Then
        ConsoleWrite($result & @TAB & $i & @CRLF)
    EndIf
Next
Link to comment
Share on other sites

It makes perfect sense if you understand binary numbers and the OR operations.

Run this and you'll see what $result is each round.

Global $result = 0
For $i = 0 To 1000
    $result = BitOR($result, $i)
;~     If $result = $i Then
        ConsoleWrite($result & @TAB & $i & @CRLF)
;~     EndIf
Next

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Yep:

$a = 8
$b = 10

ConsoleWrite($a + $b & @CRLF)
ConsoleWrite(BitOR($a, $b) & @CRLF)


#cs
Or:     0 | 1
    --+-------
    0 | 0   1
    1 | 1   1
    
8   = 1000
10  = 1010
---------------
or  = 1010
#ce

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I dont think 4 is for a beginner in the sense of a day 1 activity.  It is for a beginner in the way the 100x100 contest inspires an amateur scripter to see some awesomeness and think, I can learn what 100 lines is doing. I believe 4 would trigger the same thought in beginners "he wrote that in 36 lines? wtf? I can figure out 36 lines."

I also think any examples section that doesnt show off some of the impressive GDI+ stuff is doing a disservice, the mario clone is still in the top 3 scripts I have ever seen.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...