Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Help / Advice please...

  1. #11
    ah, I see, thanks for clarifying. Code glitch - if you're not drinking obscene amounts of coffee then maybe you've got another substance taking it's toll As for woman...I know what you mean, not entirely sure I can compare my program to them, I like it to be perfect or as perfect as I know, doubt I'll ever find the perfect woman, thats a tall order but thanks for putting it in a way that any guy should understnads.

    traveller - I just read up on procedures some more, I'm going to play woth the code some more and put the var inside the proc, again, if it makes the code cleaner then I'm all for it. I like it when the prog is clean / tidy. thanks for pointing out the numcheck bit, it's things likethat that I don't notice striaght away. thanks. I'l post the next installment a bit later for your perusal.

    on the offchance...I'm puttign a website together (again this is an assignment that I wanted to take to the next level.) www.webdesignprofessionals.co.uk (any constructive criticism woudl be awesome.

  2. #12
    Hi guys,

    still having a couple of minor issues (by minor I mean...it's not working)

    I've got the same code as before, tidied it up a bit and put the var withing the procedures to make them local

    Code:
    program EX7NOSORT(input,output);
    uses    crt;
    var     posi,negi,zero:integer;
    
    heelo & press ret to cont proc
    
    procedure AskNumber;
    var numcheck:integer;
    begin
            writeln('What number/s would you like to check?');
            read(numcheck);
           begin---------------------added to test
            if  numcheck>0 then writeln('This is a positive number');
            read(posi);---------------------added to test
            if  numcheck<0 then writeln('This is a negative number');
            read(negi);---------------------added to test
            if  numcheck=0 then writeln('This number is Zero');
            read(zero);---------------------added to test
            end;
    end;
    
    procedure AskTotal;
    
    var count,totnum:integer;
    begin
            writeln;
            writeln('How many numbers will you like to check? ');
            readln(totnum);
    
            for count:= 0 to totnum-1 do AskNumber
    end;
    
    begin {main program}
           hello;
           AskTotal;
           writeln(posi);---------------------added to test
           cont;
                           {up to 33750}
    
    end.
    I tried several variations of read(posi) etc and write and i get nothing, the closest ic ame was when it displayed 3 zero's(when pos & neg were selected) I figure if I can get it to print one then I can work from there.
    It seems when I put the read lns in the code doesn't crash but i have to input several numbers and carriage returns before it asks the next number, then repeats until tot numbers has been reached.
    I'm a wee bit stuck, I thought by adding a begin / add it might separate the prog but no. I think I might have to ask chief(tutor) for help on this.
    It looked so easy to do as well! AGGGH!!!!!

  3. #13
    In pseudo code, you're now doing this.
    Code:
    Start program
    Ask user to input an amount of numbers
    loop over the given amount each time doing :
       1) ask for a number
       2) read the number into memory
       3) check if number is great than zero and write output to screen
       4) wait for user to input something
       5) check if number is below zero and write output to screen 
       6) wait for user to input something
       7) check if number is equal to zero and write output to screen  
       8) wait for user to input something  //end of loop
    write the value of posi to screen
    You should change this so that it looks more like this:
    Code:
    Start program
    initialize variables posi,negi,zero to 0
    Ask user to input an amount of numbers
    loop over the given amount each time doing :
       1) ask for a number
       2) read the number into memory
       3) check if number is great than zero. If this is true then 
                write output to screen
                save this instance to variable posi .
           if this is not true then
       4) check if number is below zero. If this is true then
               write output to screen 
               save this instance to a variable negi.
           if this is not true then
       5) check if number is equal to zero. If this is true then 
               write output to screen 
               save this instance to variable zero //end of loop
    write the value of posi, negi and zero to screen
    end program.

  4. #14

    tried...

    I tried what you suggested and I did have some success but...still more questions...

    Code:
    begin
            writeln('What number/s would you like to check?');
            read(numcheck);
           
    posi:=0;negi:=0;zero:=0
            if  numcheck>0 then writeln('This is a positive number');
            read(posi);
            if  numcheck<0 then writeln('This is a negative number');
            //read(negi);---------------------added to test
            if  numcheck=0 then writeln('This number is Zero');
           // read(zero);---------------------added to test
            end;
    end;
    Couple of problems that I can't seem to navigate, I've tried several
    options.when i have the read statements after each line it forces me
    to press a number a certain number of times before asking for the next
    number. for example, if i say the first number to check is 5, i thne
    have to input a number 5 times before moving on to the next one.
    I can eliminate this by commenting out the other read lines as above.
    although it stills asks for another number at the end of the statement
    before moving on. this is minor though I guess.
    I've tried variations of:
    Code:
    posi:=0;negi:=0;zero:=0
            if  numcheck>0 then writeln('This is a positive number');
            read(posi);posit:=posi;
    
    -----------------
    posi:=0;negi:=0;zero:=0
            if  numcheck>0 then writeln('This is a positive number');
            read(posi);posit:=posi+1;
    ------------------------
    also tried it in the writlen at the end of the prog, tried to group
    together as well. I think there is just something fundamentally wrong
    that I'm not understanding. I'm also now thinking that the read is
    not doing as I want. It needs to count the number of posi that are
    entered but I get mixed results, on one test it did and on another it
    simply output the number that i entered.

    Hair pulling time.

    as a side note....you guys could bang this out in a couple of minutes...I
    have a tendency to make things more complicated for myself. Is this a
    difficult task or am I a fking idiot

  5. #15
    SOLVED IT!!!!!!!!!!

    all was right but i had the initisling bit at the start of the loop, every time it repeated it reset to zero!!!! sorted!!!!! THANKYOU!!!!

  6. #16
    Quote Originally Posted by stevengreen22 View Post
    as a side note....you guys could bang this out in a couple of minutes... I have a tendency to make things more complicated for myself. Is this a
    difficult task or am I a fking idiot
    No, it is not a difficult task, but that certainly doesn't make you an idiot.

    The reason why it is difficult for you is because you appear to do two things at once.
    1) learning how to program in general, the principles.
    2) learning pascal.

    While you can do both it is much harder than when you only have to do the 2nd. The first however is the most important. Do that one right and you can apply it to any language.

  7. #17
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    You need to drink less coffee
    Ah, what would life be without faithful ol' caffeine...

    Edit: oh, and gals of course
    Last edited by code_glitch; 26-03-2011 at 10:23 AM.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  8. #18
    Hi guys,

    Thanks for point a few bits out there. You're right of course, It's hard enough learning the concept let alone the language as well, I'm also burrowing my head in php which is killing me. I handed the work i today, 15/15 for one and 14/15 for the other so not too bad at all. thankyou for all your help. No doubt i'll be posting again soon when I jump on the next mission - having to read / write to files and stuff now......yay..

  9. #19
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    read & write files? Think logically, slowly and in simple instructions. Then its simple. The more procedure to treat information the better. Oh, and dont forget the else statement in case you find data you did not expect and that sometimes its good for the program to say 'error' than hang forever that really is all theory to that bit ahead of time.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  10. #20
    Thanks code dude! I got it sorted, well the intially part of the excercise anyways, just need to print it to a file and job done. Out of curiosity...Do you know of anyone thats a dab hand in php that woudln't mind trying to "nicely" infiltrate a site i'm working on.

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •