Helppp!!!!!! lazarus / 61-Beginners ---------------------------------------------------------------------- lazarusins · 2017-05-20 16:42 Hello!Please help me. I have to crate program on lazarus for school , i am beginner.I have to make simple programm where is :  if .. then .. else ..  case .. of .. for .. to .. do .. ; while .. do .. ; repeat .. until .. ; int, round.. char, string. random. 2 funkcions an procedures. What can i make? ---------------------------------------------------------------------- Eugene Loza · 2017-05-20 16:53 Basically you can make anything you like. But personally I prefer making computer games - it's both fun and educational In your case you can make a simple guess game. Let computer think of a number 0..1000 (based on randomize -> random) And let player input some number. Computer will say something like "No, too cold", "well, that's close!", "More... much more", etc. based on how far the player's guess was. (You can organize it by  case (player's guess / computer's number)) The game will go on until player guesses the number or says "I give up!". You can easily demonstrate usage of most of those functions here. When you have something working, post it here, and people will help you to include others you're missing if you're strictly demanded to use all of those. ---------------------------------------------------------------------- lazarusins · 2017-05-20 17:04 Yes that is cool idea, but how can i make it? ---------------------------------------------------------------------- Eugene Loza · 2017-05-20 17:11 The usual approach is "start simple" and then extend your program. E.g. first just make a program that will write a string on a screen and wait for player input. Then make repeat...until, until player input equals to a specific string (e.g. "exit") Then make computer react to player's input differently depending on player's input. Now you're almost ready to make the game itself. Just make computer generate a random number and make him react depending on whether player's input is greater/smaller or equal to that number. ---------------------------------------------------------------------- lazarusins · 2017-05-20 17:16 Ohhh that sounds soo difficult.... ---------------------------------------------------------------------- Thaddy · 2017-05-20 17:24 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;{$ifdef fpc}{$mode objfpc}{$apptype console}{$endif}uses sysutils;procedure proc1;begin  Beep;end; procedure proc2;begin  Proc1;end; function func1:boolean;begin   result := Boolean(random(1));end; function func2:boolean;begin  result := true;end; var   a,b:Boolean;   c:integer = 100;   d:single = 100.1;   e:string = 'Finished homework';begin   if round(d)= c then    begin   b:=func1;     if b = func1 then     case b of       true:proc1;     false:proc2;     else       for b := false to true do       while  b = func2 do         repeat           a :=func1;         until a = b;   end;   writeln(e);   end;end. Explanation of all this is probably in your school books. But otherwise feel free to read the documentation  BTW: It IS a game... Sometimes it beeps, sometimes not. So gamble on it. ---------------------------------------------------------------------- lazarusins · 2017-05-20 17:46 Unfortunately that program is not working on my computer ---------------------------------------------------------------------- sky_khan · 2017-05-20 17:49 You are kidding right ? Tell me you are kidding. Because this must be a joke. ---------------------------------------------------------------------- Thaddy · 2017-05-20 17:49 It works. And fits all requirements. ---------------------------------------------------------------------- lazarusins · 2017-05-20 17:55 When i started programm, that at once stoped and lazarus sad "Exocution stopped" ---------------------------------------------------------------------- Thaddy · 2017-05-20 18:03 That's ok. Means that the program works... Now I have this very difficult task for you. Go to the end of the program where it reads end. (with a dot.) Now just before that write: readln; Try again. You will see that Lazarus now waits until you press Enter and then says "execution stopped". But if you run the program from a command line it already works.. The readln; is just an extra. BTW: Change the program a lot: your teacher will immediately know this is written by a village idiot that knows a heck of a lot about Pascal.... ---------------------------------------------------------------------- Handoko · 2017-05-20 18:16 Readln function maybe have not been taught in his class. His teacher will be surprised how clever the student is.  Alternatively, use several (or a lot of) for..do loops. ---------------------------------------------------------------------- lazarusins · 2017-05-20 18:19 Yes i know readln funkcion. But i dont understand the mean of this program.This program only write "Finished homework" an that is all... ---------------------------------------------------------------------- molly · 2017-05-20 18:33 Quote from: lazarusins on May 20, 2017, 08:19:50 pmYes i know readln funkcion. But i dont understand the mean of this program.This program only write "Finished homework" an that is all... Does it have to do anything 'useful' ? (note that i wrote that between quotes. What is useful for one might not be so useful for someone else). It is an attempt to incorporated all constructs that you asked for. On a quick glance only the char and int/round parts are missing. Perhaps you are able to add those yourself ? ---------------------------------------------------------------------- bytebites · 2017-05-20 18:38 It is little boring since case-statement never gets to else-branch. ---------------------------------------------------------------------- molly · 2017-05-20 18:42 And how did you came to that conclusion bytebites ? Perhaps the answer to that could give TS a hint or two. ---------------------------------------------------------------------- Thaddy · 2017-05-20 18:56 Oops. Forgot char indeed? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // add f:char after var// and replace writeln(e) with     for f in e do write(f); ---------------------------------------------------------------------- molly · 2017-05-20 19:04 lol., nice one Thaddy  , although that brings in a new construct that wasn't asked for (perhaps not even allowed ?). TS could always replace with a for-next, or while-do. ---------------------------------------------------------------------- lazarusins · 2017-05-20 19:37 Why when  i start thet programm, it dont ask me to introduce numbers, guess number that computer  had choseed....? ---------------------------------------------------------------------- molly · 2017-05-20 19:48 Quote from: lazarusins on May 20, 2017, 09:37:42 pmWhy when  i start thet programm, it dont ask me to introduce numbers, guess number that computer  had choseed....? Because that was not the aim of the program that Thaddy showed. The idea there is, that it does not matter what you come up with, as long as you yourself come up with it. I understand that things might be difficult for your, especially in case you are new to programming  or even the Pascal programming language, but are you not even capable of thinking yourself ? - understand what each of the by you mentioned constructs do, read their documentation,  test them one by one, make small test examples - combine some of the constructs to see how these can interact between each other - think of something simple that you could accomplish with using these constructs. - start programming - fail miserably, show us your code and ask question the smart way Nobody here is going to do your homework. What if the doctor that performs open heart surgery on your father/mother/brother/sister or perhaps even yourself, did the same thing you are trying to do right now and let others do his homework ? ---------------------------------------------------------------------- lazarusins · 2017-05-20 20:25 Yes i agree with you , but how can i make that programm if i know nothing at lazarus ---------------------------------------------------------------------- molly · 2017-05-20 20:35 Quote from: lazarusins on May 20, 2017, 10:25:32 pmYes i agree with you , but how can i make that programm if i know nothing at lazarus By starting at the beginning  How did you managed to do calculus and are now able to multiply 2 by 4 and come up with an answer (the moment you say "i use my calculator for that", then you are surely doomed  ) You mentioned a few constructs in your first post. Do you know what they do ? if not, then it might be a good idea to really start at the beginning and try read/understand a tutorial like this. Do you have any programming experience ? perhaps in another programming language ? You can also write what is called "pseudo-code" to at least show oyur good intentions, for example: Guessing game: - introduce game/rules to user - generate a (random) number - ask user for a number - check if number entered by user matches generated number - if no match, then let user continue guessing - if match, then inform user and end game So, you have a 'bigger' picture in your mind, and you break it up into smaller sub-parts. Make them small enough to understand and so that each part is possible for you to implement with programming statements with using the constructs you already know and/or are familiar with. Each time you learn a new construct, or feel you can't implement a certain 'sub-part' because you are missing a proper construct, you can up the ante and learn something new to try accomplish the task (or ask us what could be used to solve sub-part). ---------------------------------------------------------------------- Bart · 2017-05-20 20:47 @Thaddy: best entry for homework assignment yet. Bart ---------------------------------------------------------------------- lazarusins · 2017-05-20 20:55 Mby you can put some programm there and i will try to understand it.Yes i know what do what they do. ---------------------------------------------------------------------- jc99 · 2017-05-20 21:23 BTW: if you change the second line to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifdef fpc}{$mode objfpc}{$endif}{$apptype console} the program even runs under Delphi (just checked) ---------------------------------------------------------------------- jc99 · 2017-05-20 22:23 BTW bytebites was right, the program always beeps, Two[edit]Four changes and then it works: 1. An end - has to be moved and a semicolon has to be removed (or moved to another place). 2. A number has to be increased by one. [edit] 3. Another systemfunction has to be included. 4. Two calls have to be exchanged Happy debugging ... ---------------------------------------------------------------------- Thaddy · 2017-05-21 04:38 No, just change random(1) to random(2) if it actually needs to work. And yes it also works on Delphi. ---------------------------------------------------------------------- jc99 · 2017-05-21 11:35 That's Number two. !!!! Spoiler !!! if you don't call randomize at the beginning the program generates random numbers/booleans, but the same every time you run the program. (that would be No. 3) But you are right the others can be omitted. [edit] ... but isn't it more fun if the program uses (nearly) all of it's angles & corners ?