Page 1 of 2

Help!

Posted: Tue Oct 11, 2011 5:00 pm
by x-GAMBIT-x
Getting stuck on my Command Line assingment and need to move onto other assignments. Here is my assignment, attached here. Also getting stuck on my Inrto to Programming class working with Python 3. Can't stand either of these classes. Some is cool to learn but just hard to catch on for me.

Any help I get Thanks.

Re: Help!

Posted: Tue Oct 11, 2011 6:20 pm
by Ghosted
Lemme preface that batch is horrible and I go out of my way not to use it. You should recommend to your teacher that she teach something useful like powershell. You will not pick up any good habits using batch. At least you guys are using Python as well. That's a great beginner language.

Here's a working example, but I've implemented it stupidly so you can correct some things.

1) You only have the illusion of choice, they all go to the same place. You will probably be marked lower for this.
2) Part of your problem was that you had no control flow in your if statements (read gotos). It would always fall through to invalid choice which kicked you into a loop. I took that out because it was annoying.
3) Try tracing where the program is going by writing a line down until you hit a jump statement, then jump to that statement. It's pretty simple.

[Note the @ symbols tell the console to not output the command text]

@set /p choice="Choose option A, B or C:"
@if %choice%==A ( goto Exit )
@if %choice%==B ( goto Exit )
@if %choice%==C ( goto Exit )

:invalidchoice
@echo you have selected an invalid choice

:Exit
@echo You selected %choice%

Re: Help!

Posted: Tue Oct 11, 2011 6:44 pm
by ru_exp
I don't wtf he just said but I'd hit that.


:x

Re: Help!

Posted: Tue Oct 11, 2011 7:25 pm
by Mr Bean
word

Re: Help!

Posted: Tue Oct 11, 2011 7:35 pm
by Hermit
This might not help with the above problem but
check out this http://www.youtube.com/watch?v=qybUFnY7 ... yer_popout
it is very interesting and funny

Re: Help!

Posted: Tue Oct 11, 2011 8:03 pm
by x-GAMBIT-x
Ghosted wrote:Lemme preface that batch is horrible and I go out of my way not to use it. You should recommend to your teacher that she teach something useful like powershell. You will not pick up any good habits using batch. At least you guys are using Python as well. That's a great beginner language.

Here's a working example, but I've implemented it stupidly so you can correct some things.

1) You only have the illusion of choice, they all go to the same place. You will probably be marked lower for this.
2) Part of your problem was that you had no control flow in your if statements (read gotos). It would always fall through to invalid choice which kicked you into a loop. I took that out because it was annoying.
3) Try tracing where the program is going by writing a line down until you hit a jump statement, then jump to that statement. It's pretty simple.

[Note the @ symbols tell the console to not output the command text]

@set /p choice="Choose option A, B or C:"
@if %choice%==A ( goto Exit )
@if %choice%==B ( goto Exit )
@if %choice%==C ( goto Exit )

:invalidchoice
@echo you have selected an invalid choice

:Exit
@echo You selected %choice%
Thanks Ghosted that worked great.
Now! do you want to do my Python assingment for me... :mrgreen:
Yeah, the Into to Programming (Python 3) is required to take for a Computer Tech Support and I will more than likely never use it after school. I'm about a week or two behind on some of my assignments, Some I work on for hours then have to start all over "I hate this CRAP"

Re: Help!

Posted: Tue Oct 11, 2011 11:43 pm
by Mr Bean
Hermit wrote:This might not help with the above problem but
check out this http://www.youtube.com/watch?v=qybUFnY7 ... yer_popout
it is very interesting and funny

Re: Help!

Posted: Wed Oct 12, 2011 5:20 am
by CTC-JimRimya
Extra credit: Make the code accept both upper case and lower case entries as valid (not just upper case)
Also, as ghosted said, powershell is so much more useful... even VBS under WSH would be better than batch.

Re: Help!

Posted: Thu Oct 13, 2011 12:12 am
by x-GAMBIT-x
CTC-JimRimya wrote:Extra credit: Make the code accept both upper case and lower case entries as valid (not just upper case)
Also, as ghosted said, powershell is so much more useful... even VBS under WSH would be better than batch.
Yeah, the batchfile is just one of the many things that the instuctor is teaching for basic command line use. The instrctor just showed a few so far on some of the basic command phrases used in them "I Guess". Powershell is for a programming class except now they don't use it now, instead they use Python 3 now. Although we did learn a little bit of powershell in server classes. I guess for Computer Tech Support peeps, they just want us to have a basic understanding for them and what programmers do. Something like that.

Re: Help!

Posted: Thu Oct 13, 2011 3:39 am
by Hermit
Thank you "Mr.Bean" for inserting the "Picture Link with the arrow"
below my "written link" only. I clicked first on "URL" did not work so I tried
clicking on "Img" but still no luck. Now you put it in the correct way and thanks again.
I also clicked on to your website and downloaded the nice maps. Very impressive.

Re: Help!

Posted: Thu Oct 13, 2011 4:23 am
by MikeFiend

Re: Help!

Posted: Thu Oct 13, 2011 12:14 pm
by Mr Bean
Hermit wrote:Thank you "Mr.Bean" for inserting the "Picture Link with the arrow"
below my "written link" only. I clicked first on "URL" did not work so I tried
clicking on "Img" but still no luck. Now you put it in the correct way and thanks again.
I also clicked on to your website and downloaded the nice maps. Very impressive.
- Don't copy the whole URL, only this qybUFnY7Y8w
- Paste that part of the URL here in the forum
- Hi-lite the code you just pasted and click the "youtube" button

Try the same on Mike's Beatles 'Help!' post. I love that song. Glad you like my little projects.

Re: Help!

Posted: Thu Oct 13, 2011 2:40 pm
by WeedVulture
gambit,
1+3+3=7
hope this helps.

Re: Help!

Posted: Thu Oct 13, 2011 9:16 pm
by rimmer59
WeedVulture wrote:gambit,
1+3+3=7
hope this helps.
gambit,
1+1/2+1/2+5=7
hope this helps.

Re: Help!

Posted: Thu Oct 13, 2011 9:42 pm
by WarDad71
rimmer59 wrote:
WeedVulture wrote:gambit,
1+3+3=7
hope this helps.
gambit,
1+1/2+1/2+5=7
hope this helps.
Weed's post is LEET :wink: