Help With Some Pascal???

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2008
Posts: 26
Reputation: sura17 is an unknown quantity at this point 
Solved Threads: 0
sura17 sura17 is offline Offline
Light Poster

Help With Some Pascal???

 
0
  #1
Feb 4th, 2008
i have to do a seven segemtn display for 2 numbers but at the moment it looks like this:- http://i28.tinypic.com/a176ep.jpg but i want the 1 and 3 to be next to each other but i cannot seen to do this here is my pascal:-

Pascal and Delphi Syntax (Toggle Plain Text)
  1. Program sevensegmentdigit;
  2. Uses Wincrt;
  3.  
  4. Var
  5. x,y,n1,n2 : integer;
  6.  
  7. Procedure One;
  8. begin
  9. writeln(' ');
  10. writeln(' |');
  11. writeln(' |');
  12. end;
  13.  
  14. procedure Two;
  15. begin
  16. writeln(' _ ');
  17. writeln(' _|');
  18. writeln('|_ ');
  19. end;
  20.  
  21. procedure Three;
  22. begin
  23. writeln(' _ ');
  24. writeln(' _|');
  25. writeln(' _|');
  26. end;
  27.  
  28. procedure Four;
  29. begin
  30. writeln(' ');
  31. writeln('|_|');
  32. writeln(' |');
  33. end;
  34.  
  35. procedure Five;
  36. begin
  37. writeln(' _ ');
  38. writeln('|_ ');
  39. writeln(' _|');
  40. end;
  41.  
  42. procedure Six;
  43. begin
  44. writeln(' _ ');
  45. writeln('|_ ');
  46. writeln('|_|');
  47. end;
  48.  
  49. procedure Seven;
  50. begin
  51. writeln(' _ ');
  52. writeln(' |');
  53. writeln(' |');
  54. end;
  55.  
  56. procedure Eight;
  57. begin
  58. writeln(' _ ');
  59. writeln('|_|');
  60. writeln('|_|');
  61. end;
  62.  
  63. procedure Nine;
  64. begin
  65. writeln(' _ ');
  66. writeln('|_|');
  67. writeln(' |');
  68. end;
  69.  
  70. procedure Zero;
  71. begin
  72. writeln(' _ ');
  73. writeln('| |');
  74. writeln('|_|');
  75. end;
  76.  
  77. Begin
  78.  
  79. write('Is Your Number 1 or 2 Digits?...');
  80. readln(y);
  81.  
  82. if y = 1 then
  83.  
  84. begin
  85.  
  86. write('Enter Number...');
  87. readln(x);
  88.  
  89. if x = 1 then
  90. begin
  91. One
  92. end;
  93.  
  94. if x = 2 then
  95. begin
  96. Two
  97. end;
  98.  
  99. if x = 3 then
  100. begin
  101. Three
  102. end;
  103.  
  104. if x = 4 then
  105. begin
  106. Four
  107. end;
  108.  
  109. if x = 5 then
  110. begin
  111. Five
  112. end;
  113.  
  114. if x = 6 then
  115. begin
  116. Six
  117. end;
  118.  
  119. if x = 7 then
  120. begin
  121. Seven
  122. end;
  123.  
  124. if x = 8 then
  125. begin
  126. Eight
  127. end;
  128.  
  129. if x = 9 then
  130. begin
  131. Nine
  132. end;
  133.  
  134. if x = 0 then
  135. begin
  136. Zero
  137. end;
  138.  
  139. end;
  140.  
  141. if y = 2 then
  142. begin
  143. writeln('Enter First Number...');
  144. readln(n1);
  145. writeln('Enter Second Number...');
  146. readln(n2);
  147.  
  148. if n1 = 1 then
  149. begin
  150. One;
  151. end;
  152.  
  153. if n1 = 2 then
  154. begin
  155. Two;
  156. end;
  157.  
  158. if n1 = 3 then
  159. begin
  160. Three;
  161. end;
  162.  
  163. if n1 = 4 then
  164. begin
  165. Four;
  166. end;
  167.  
  168. if n1 = 5 then
  169. begin
  170. Five;
  171. end;
  172.  
  173. if n1 = 6 then
  174. begin
  175. Six;
  176. end;
  177.  
  178. if n1 = 7 then
  179. begin
  180. Seven;
  181. end;
  182.  
  183. if n1 = 8 then
  184. begin
  185. Eight;
  186. end;
  187.  
  188. if n1 = 9 then
  189. begin
  190. Nine;
  191. end;
  192.  
  193. if n1 = 0 then
  194. begin
  195. Zero;
  196. end;
  197.  
  198.  
  199. if n2 = 1 then
  200. begin
  201. One;
  202. end;
  203.  
  204. if n2 = 2 then
  205. begin
  206. Two;
  207. end;
  208.  
  209. if n2 = 3 then
  210. begin
  211. Three;
  212. end;
  213.  
  214. if n2 = 4 then
  215. begin
  216. Four;
  217. end;
  218.  
  219. if n2 = 5 then
  220. begin
  221. Five;
  222. end;
  223.  
  224. if n2 = 6 then
  225. begin
  226. Six;
  227. end;
  228.  
  229. if n2 = 7 then
  230. begin
  231. Seven;
  232. end;
  233.  
  234. if n2 = 8 then
  235. begin
  236. Eight;
  237. end;
  238.  
  239. if n2 = 9 then
  240. begin
  241. Nine;
  242. end;
  243.  
  244. if n2 = 0 then
  245. begin
  246. Zero;
  247. end;
  248.  
  249. end;
  250.  
  251. End.


can some help me do this plz thank you
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,953
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Help With Some Pascal???

 
0
  #2
Feb 4th, 2008
How non-standard are you willing to go?

The standard way, you will have to re-write your program to take a whole number and create a string for each part of the number.

For example, if given the number '42', you would make the strings
Pascal and Delphi Syntax (Toggle Plain Text)
  1. 1: ' _ '
  2. 2: ' |_| _|'
  3. 3: ' | |_ '

If your numbers are always three lines high, this is easy enough. Just adjust your functions to append the correct stuff to the end of the strings instead of using writeln.

Then, once you are done calling the zero, one, two, etc. functions, writeln each of the three strings to the screen.


BTW, use a case statement instead of a zillion ifs.

Hope this helps.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 26
Reputation: sura17 is an unknown quantity at this point 
Solved Threads: 0
sura17 sura17 is offline Offline
Light Poster

Re: Help With Some Pascal???

 
0
  #3
Feb 5th, 2008
i dont really understand can you explain that a bit more please
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,953
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Help With Some Pascal???

 
0
  #4
Feb 5th, 2008
You need to write three separate lines of text for each number, right? But all the numbers must be horizontally arranged? So, get yourself three string variables and set them to the empty string to begin with:
  1. var s1, s2, s3: string;
  2. begin
  3. s1 := '';
  4. s2 := '';
  5. s3 := '';

Now, each number routine (zero, one, two, etc.) can add itself to the end of the strings.
  1. procedure zero;
  2. begin
  3. s1 := s1 +' _ ';
  4. s2 := s2 +'| |';
  5. s3 := s3 +'|_|'
  6. end;

When done, you can print the strings with writeln:
  1. writeln( s1 );
  2. writeln( s2 );
  3. writeln( s3 );

Hope this helps.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 26
Reputation: sura17 is an unknown quantity at this point 
Solved Threads: 0
sura17 sura17 is offline Offline
Light Poster

Re: Help With Some Pascal???

 
0
  #5
Feb 5th, 2008
this doesnt really seem to work as i cant get them to be next to each other
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 71
Reputation: Micheus is an unknown quantity at this point 
Solved Threads: 4
Micheus's Avatar
Micheus Micheus is offline Offline
Junior Poster in Training

Re: Help With Some Pascal???

 
0
  #6
Feb 5th, 2008
Originally Posted by sura17 View Post
this doesnt really seem to work as i cant get them to be next to each other
You must test the code that Duoas post for You. I think You don't.

Just try Duoas's code by other way - may be You can see:
  1. var s1, s2, s3: string;
  2.  
  3. procedure zero;
  4. begin
  5. s1 := s1 +' _ ';
  6. s2 := s2 +'| |';
  7. s3 := s3 +'|_|';
  8. end;
  9.  
  10. procedure PrintResult;
  11. begin
  12. writeln( s1 );
  13. writeln( s2 );
  14. writeln( s3 );
  15. end;
  16.  
  17. begin
  18. s1 := '';
  19. s2 := '';
  20. s3 := '';
  21.  
  22. zero; // 1st digit
  23. zero; // 2nd digit
  24.  
  25. PrintResult;
  26. end.
You will see this:
Pascal and Delphi Syntax (Toggle Plain Text)
  1. _ _
  2. | || |
  3. |_||_|
"It always has, at least, two ways to make one same thing. Exactly that they are certain and wrong"(Micheus)

Brazil - Blumenau
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 26
Reputation: sura17 is an unknown quantity at this point 
Solved Threads: 0
sura17 sura17 is offline Offline
Light Poster

Re: Help With Some Pascal???

 
0
  #7
Feb 5th, 2008
but i wnt the user to type in say 24 and 24 comes up
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 71
Reputation: Micheus is an unknown quantity at this point 
Solved Threads: 4
Micheus's Avatar
Micheus Micheus is offline Offline
Junior Poster in Training

Re: Help With Some Pascal???

 
0
  #8
Feb 6th, 2008
Originally Posted by sura17 View Post
but i wnt the user to type in say 24 and 24 comes up
And You have had implement this at first. You just will need to use the code that You post at first in this thread and change it by using the Douas approach.

Your code was working. Isn't it right?
So, You just need to surronud display "problem" - It is that the Duoas had suggested to You. I just examplefy with Zero's procededure, You will need to change Your others number's procedures to use some thing like this: s1 := s1 +' |' ; and not some thing like this: writeln(' |');

bye
"It always has, at least, two ways to make one same thing. Exactly that they are certain and wrong"(Micheus)

Brazil - Blumenau
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 26
Reputation: sura17 is an unknown quantity at this point 
Solved Threads: 0
sura17 sura17 is offline Offline
Light Poster

Re: Help With Some Pascal???

 
0
  #9
Feb 6th, 2008
thanks for the advice i got this woroking, ive been working on this for over a week lol after 5 days i asked for help, thanks guys
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 26
Reputation: sura17 is an unknown quantity at this point 
Solved Threads: 0
sura17 sura17 is offline Offline
Light Poster

Re: Help With Some Pascal???

 
0
  #10
Feb 6th, 2008
thanks for the advice i got this woroking, ive been working on this for over a week lol after 5 days i asked for help, thanks guys
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC