Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: goto issues  (Read 8733 times)

0 Members and 1 Guest are viewing this topic.

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: goto issues
« Reply #15 on: December 01, 2014, 11:02:00 PM »
You need to define enter at the top of your code.
Don't blame the IF structure.
In batch and in Ch and C you must define or  set variables at the start. With a few exceptions.
As for distribution, Ch is so close to C or C++ that you should be able to compile it and distribute it asa an EXE file after you have the code perfected. But If you want others to help you with it, you can give them the link to the free CH IDE.
Here are three resins I would recommend Ch rather that batch as a general tool.
• It has structure  closer to C/C++ and can be ported to other platforms.
• It is a better learning tool that batch.
• It comes with a nice IDE. (Integrated Development Environment)

But if you want to use batch. bot ahead. Every time you have a IF statement there must be a GOPTO after it. Unless you are very clever.

BTW, there is also Tiny C,which has a very long history. It can be compiled.
http://bellard.org/tcc/
It does very compact x86 code.

omnominous

    Topic Starter


    Rookie
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 7
    Re: goto issues
    « Reply #16 on: December 02, 2014, 03:25:37 PM »
    i defined enter at the top but it is displaying everything like i had said before in the previous reply

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: goto issues
    « Reply #17 on: December 02, 2014, 04:24:00 PM »
    i defined enter at the top but it is displaying everything like i had said before in the previous reply
    I didn't  see it.  Overall, your CH looks good. I still think you will do better in Ch rater than batch. Butch is weird.
    Give me some time to run over your Ch code.

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: goto issues
    « Reply #18 on: December 02, 2014, 07:48:58 PM »
    If you are going to program this in another language then please report this post and ask the moderators to move this thread to that forum category.

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: goto issues
    « Reply #19 on: December 02, 2014, 09:21:36 PM »
    If you are going to program this in another language then please report this post and ask the moderators to move this thread to that forum category.
    My apology for diverting this thread. :-[

    I look at the C code the OP had and I see not reason to convert it to batch, other than  the fact that distributing it is more work.
    But Ch and Tiny C are freeware programs and can be made available to anyone.

    Perhaps the OP will express his preference again.  :)

    omnominous

      Topic Starter


      Rookie
      • Computer: Specs
      • Experience: Familiar
      • OS: Windows 7
      Re: goto issues
      « Reply #20 on: December 03, 2014, 12:19:43 PM »
      My apology for diverting this thread. :-[

      I look at the C code the OP had and I see not reason to convert it to batch, other than  the fact that distributing it is more work.
      But Ch and Tiny C are freeware programs and can be made available to anyone.

      Perhaps the OP will express his preference again.  :)
        i would like to go back to using Ch because it is an ok program to use.. and i can work on it at school because it is installed on the computers.. well one class.. i wish the library would have it so i can work on it there. i could pull out a 32bit pc and download Ch to my flash drive and use it off of it because i have the 64bit that i use on my flash drive already.

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Using Ch as a portable IDE for C pprogrfamming.
      « Reply #21 on: December 03, 2014, 12:58:39 PM »
      The 32 bit version works on any Windows computer. After finding  the error with enter it runs normally. Ch can be installed on a flash drive and run on any Windows PC. For all piratical purposes it is a portable program and does not need to alter the system environment. Provided you put your source code in the same directory.

      Glad to hear you school is using an interpreter to teach programming. After about twenty years the schools are now helping students learn tools that are relevant to the current state of the art in the commercial world.

      MODERATOR. Can the thread be moved into programming?


      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Using Ch as a portable IDE for C pprogrfamming.
      « Reply #22 on: December 03, 2014, 01:59:38 PM »
      MODERATOR. Can the thread be moved into programming?
      That is what the Report to Moderator link is for.

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Using Ch as a portable IDE for C pprogrfamming.
      « Reply #23 on: December 03, 2014, 02:18:54 PM »
      That is what the Report to Moderator link is for.
      OK. Did it.

      omnominous

        Topic Starter


        Rookie
        • Computer: Specs
        • Experience: Familiar
        • OS: Windows 7
        Re: Using Ch as a portable IDE for C pprogrfamming.
        « Reply #24 on: December 03, 2014, 02:26:39 PM »
        The 32 bit version works on any Windows computer. After finding  the error with enter it runs normally. Ch can be installed on a flash drive and run on any Windows PC. For all piratical purposes it is a portable program and does not need to alter the system environment. Provided you put your source code in the same directory.

        Glad to hear you school is using an interpreter to teach programming. After about twenty years the schools are now helping students learn tools that are relevant to the current state of the art in the commercial world.

        MODERATOR. Can the thread be moved into programming?
        the 32 bit version wouldn't work on my 64 bit pc... and there is obviously a problem with the code because it is outputting everything at once after I do 1 and then 1 again...

        Geek-9pm


          Mastermind
        • Geek After Dark
        • Thanked: 1026
          • Gekk9pm bnlog
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: goto issues
        « Reply #25 on: December 03, 2014, 10:24:04 PM »
        (The OP is now doing his game in Ch, a fast interpreter that conforms to C99 rules. His code now is free of syntax error, but has logical errors.)

        I will check the the 32 bit version of Ch on my other machine. I think it should work.
        Here is the revised code from the OP. ( sent it via PM)
        Code: [Select]
        /*File: interactive story*/
        #include <stdio.h>
        int main ()
        {
        int house;
        int forest;
        int poster;
        int knock;
        int thinking;
        int enter;
        printf("you are in an open forest west of a big abandoned house.\n");
        printf("you can see that the front door is boarded up one window is open\n");
        printf("there is a poster\n");
        printf("if you want to look at poster type 1 if you want to pass press 2\n");
        scanf("%d", &poster);
            if  (poster == 1);
            {
        printf("Welcome to the interactive story of idk!\n");
        printf("\n");
        printf("you can explore a haunted house or a forest in this chapter\n");
        printf("\n");
        printf("you are in an open forest west of a big abandoned house.\n");
        printf("you can see that the front door is boarded up one window is open\n");
        printf("if you want to go into the spooky house press 1\n");
        printf("if you want to go to the forest press 2\n");
        scanf("%d", &house);
        scanf("%d", &forest);
                if (house == 1);
                {
                    printf("you are walking up to the white house.\n");
                    printf("you hear a noise inside. do you want to knock or enter? 1 for knock or 2 for enter.\n");
                    scanf("%d", &knock);
                    if(knock == 1);
                    {
                        printf("a big unknown thing breaks down the door and eats you whole. you are dead!\n");
                    }
                    if(enter == 2);
                        {
                        printf("you open the door and see this tall boney grey thing sitting\n");
                        printf("on the floor eating something fleshy.\n");
                        printf("you see a shotgun leaning up against a rocking chair. you are thinking about\n");
                        printf("picking up the shotgun and shooting it or try to reason with it. 1 for reason or 2 for shoot\n");
                        scanf("%d", &thinking);
                    if(thinking == 1);
                        {
                        printf("you say hello and asks what he is doing and it says not a word and rips you in two.\n");
                        printf("bad ending\n");
                     }
                 
                    if(thinking == 2);
                        {
                        printf("you run and grab the shotgun. the big grey thing turns and looks at you as you blow its head off.");
                    }
                }
            }
        }
        }

        Looks like he has too many left brackets.
        Anybody?  :)