Understanding Logic and Flow better


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Understanding Logic and Flow better
# 1  
Old 07-01-2009
PHP Understanding Logic and Flow better

i am in an epic quagmire of horrid misunderstanding.

its been a while since ive been in the scene, couldnt remember my login for the account i used to have here, so excuse the 1st post. i dont want it to seem like ima post n boogy. in any case here we go:

just recently installed mandriva one 2009 to run away from Ubuntu. working great, got everything configured so i figured it would be a great time to try and jump back in where i left off and try and get some scripting under my belt. ive made petty shots at other languages like PERL and C and whatnot before, but my mind always gets scattered when it comes to a certain point.

You know in EVERY programming book, right after learning about variables you start to learn about those dreaded LOOPS and CASES! yeah..... everytime, thats when things start going downhill in a hurry. I figure attempting to learn the logic and flow using scripting would be a good stepping stone before hitting a massive language. but the main reason for this post is this.

"Does anybody have some tips on understanding and mapping out the logic and flow of scripts"

ive dont the whole, write the outline of the program and fill in the code, to no avail. and obviously practice makes perfect. but i kid you not, ive been sitting here for 8 hours and on my 3rd pot of coffee nailed down solo reading Shell Programming in 24 Hours... and im ahead of schedule.... for a little bit at least. Doing the exercises is something ive been making attempts at, but in all reality, im trying to find a way to idealize whats happening better and was hoping one of the guru's here could offer some assistance for a lil starter boy.

i appreciate whatever responses come in advance, and i look forward to hopefully un-knotting my nuerons. theyre kinda upset between the heavy doses of coffee and the non-stop CRT Screen watchin. take care and thanks again!
# 2  
Old 07-01-2009
I'm sure there are pages which include helps for you.

I have done something, but language is mostly finnish.
Karjalan ATK-Awot Oy
Ofcourse you can look those pages using Googles translator
Google Kääntäjä


if command I have done page using my english. Why ? If has used so often like programlanguage if. If command is different. Same situation with ex. case.
Karjalan ATK-Awot Oy

Big idea is to understand that everyline is commandline = works same way even command is builtin if, case, ... or something else like date, ls, rm, ...
- filename generation
- pipe
- io-redirection
- argument delimeter !!! (ex. if ...)
- ...

Example
Code:
ls * 
echo *
if cp x y 2>/dev/null ; then
   print ok
else
   print not so good
fi

I'm sure, you get other links also.
# 3  
Old 07-01-2009
Quote:
"Does anybody have some tips on understanding and mapping out the logic and flow of scripts"
First, you're rambling; get some sleep (if you can after 3 pots of coffee).

Second, "scripts" are usually executed in order the lines appear in the program, with the exception of things like loops. SH and derivatives (bash, zsh) handle functions, and these functions need to be defined before they are invoked. Other than that, it's pretty straight-forward.

*Sigh* then again, I've been coding since I was 10.

Third: You must understand Binary Logic (aka, Boolean Logic). The keys are understanding the basic operators: OR, AND, NOT. If you don't understand these correctly, you'll have a hard time. In most modern languages, including shell scripting, perl, and C, the operands can be expressions which means in the case of shell scripting, a program that returns an exit code.

So fourth, you have to understand that programs return exit codes. If the exit code is numerically 0, that means true. (0 for true is known sometimes as "negative logic").

If you are visually oriented, this tutorial might help.
I googled around and found this video which might help: YouTube - Prelude to Computer Science - 6: Binary Logic and YouTube - Prelude to Computer Science - 7: Logic Gates
# 4  
Old 07-01-2009
thanks for the reply, see the main problem was, during my quest to understand logic and flow control better, i didnt really know what term/s to search for. boolean...thats right, now i remember it from teh days of yore.

the links have been helpful, its just up to me as to what i do with them. one more thing, is it ok if i PM one of you when im stuck trying to understand a concept or code. id rather run to a single person after i cant find the answer whilst RTFM and dont want to waste space posting such a small easy to answer problem on the boards. thanks again guys!
# 5  
Old 07-01-2009
Quote:
is it ok if i PM one of you when im stuck trying to understand a concept or code
It's against the rules. If you do that, make sure they won't enforce the rules on you!

Quote:
dont want to waste space posting
The disk space has been purchases and is just waiting to be filled with your questions and answers.

Just reply here, and I'll see the post.
# 6  
Old 07-01-2009
Quote:
Originally Posted by otheus
It's against the rules. If you do that, make sure they won't enforce the rules on you!


The disk space has been purchases and is just waiting to be filled with your questions and answers.

Just reply here, and I'll see the post.
the prior was just sending out a call to ask for individuals permission to PM not just sending random ones out to people, if that is against the rules, i didnt know that sending PM's between 2 consenting individuals was against the rules.

so if thats the case, then they shall be posted, i just didnt want to get scolded for not looking for the answers hard enough on my own.
# 7  
Old 07-01-2009
Quote:
i didnt know that sending PM's between 2 consenting individuals was against the rules.
Oh, that's not against the rules. Just make sure the other party is consenting.
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help understanding aspell logic

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am working on a script to create a spell check assignment. I have the code written , but it is not working. To... (1 Reply)
Discussion started by: nikkoNIU
1 Replies

2. Programming

logic understanding for inter client chat server

hello everyone, i am making chat server in linux using c. i have made programs in which group chat can take place between multiple clients but i am not able to understand how to make 2 particular clients chat with each other. please help!!! (1 Reply)
Discussion started by: sweetbella
1 Replies
Login or Register to Ask a Question