* * *

Author Topic: i create some program of auto-web-page-programming but there's a problem  (Read 220 times)

whitehat

  • Jr. Member
  • **
  • Posts: 51
hello this is a short program for my school homework our homework is about creating a program that allow the people who don't know how to program to create his own website without knowing any language of web-developing language beetwen whe just use a old version of lazarus + wincrt library there's some problem in my program i'm new in programming but i learn from my mistake every time can any one tell me how can i fix this problem
Code: Pascal  [Select]
  1.  
  2. program best;
  3. uses wincrt;
  4. type
  5. tab = array [1..20] of string;
  6. var
  7. reponse:integer;
  8. t:tab;
  9. f:text;
  10. procedure remplirehtml(var t:tab);
  11. begin
  12. t[1]:='<html>';
  13. t[2]:='<head>';
  14. end;
  15.  
  16. procedure icon (var t:tab);
  17. var
  18. posico:integer;
  19. iconn:string;
  20. begin
  21. t[3]:='<link rel="stylesheet" href="">';
  22. writeln('si tu veux tu peux mettre une icon dans votre site');
  23. readln(iconn);
  24. posico:=pos('""',t[3])+1;
  25. insert(iconn,t[3],posico);
  26. end;
  27.  
  28. procedure title (var t:tab);
  29. var
  30. i:integer;
  31. titre,tit:string;
  32. co:integer;
  33. begin
  34. t[4]:='<title></title>';
  35. writeln('donner le titre de page >');
  36. readln(titre);
  37. co:=pos('/',t[4])-1;
  38. insert(titre,t[4],co);
  39. end;
  40.  
  41. procedure script (var t:tab);
  42. var
  43. sc1,sc:integer;
  44. scr1,a,scr:string;
  45. begin
  46. t[5]:='<style> input[type=text] {width: %;padding: 12px 20px;margin: 8px 0;';
  47. a:='box-sizing: border-box;border: 2px solid ;border-radius: 4px;}</style>';
  48. writeln('donner le width a votre form');
  49. readln(scr);
  50. sc:=pos('%',t[5]);
  51. insert(scr,t[5],sc);
  52. t[5]:=t[5]+a;
  53.  
  54. writeln('donner le coleur de votre form (input)');
  55. readln(scr1);
  56. sc1:=pos(';border-radius',t[5]);
  57. insert(scr1,t[5],sc1);
  58. end;
  59.  
  60. procedure bodyf (var t:tab);
  61. begin
  62. t[6]:='</head>';
  63. end;
  64.  
  65. procedure background (var t:tab);
  66. var
  67. up,backg,back,ch:string;
  68. k:integer;
  69. begin
  70. {background page or image}
  71. writeln('backgournd or color');
  72. readln(back);
  73. {choix d'image}
  74. t[7]:='<body background="">';
  75. if back ='background' then
  76. begin
  77.  
  78. write ('image url ? / image dans votre PC (url/pc):');
  79. readln(up);
  80. if up = 'url' then
  81. begin
  82. write('donner l''url de background : ');
  83. readln(backg);
  84. k:=pos('""',t[7])+1;
  85. insert(backg,t[7],k);
  86. end
  87. else if up ='pc' then
  88. begin
  89. writeln('donner le chemin de background : ');
  90. readln(backg);
  91. k:=pos('""',t[7])+1;
  92. insert(backg,t[7],k);
  93. end ;
  94. end;
  95.  
  96. {choix de background color not image}
  97. if back='color' then
  98. begin
  99. t[8]:='<body bgcolor="">';
  100. writeln('donner le coleur : ');
  101. readln(backg);
  102. k:=pos('""',t[8])+1;
  103. insert(backg,t[8],k);
  104. end;{delete write(ch) ==> test}
  105. end;
  106.  
  107. procedure h (var t:tab);
  108. var
  109. ch7,ch4,ch2,k2,k3:integer;
  110. i:string;
  111. ch8,ch6,ch3,ch:string;
  112. begin
  113.  
  114. writeln('donner h? :');
  115. readln(i);
  116. write('donner le coleur de h: ');
  117. readln(ch3);
  118. t[9]:='<h align="" style="color:;"></h>';
  119. k3:=pos('h',t[9])+1;
  120. insert(i,t[9],k3);
  121. ch:=copy(t[9],pos(i,t[9]),1);
  122. k2:=length(t[9]);
  123. insert(ch,t[9],k2);
  124. ch2:=pos('color:',t[9])+6;
  125. insert(ch3,t[9],ch2);
  126. writeln('donner l''align (center/right/left)');
  127. readln(ch6);
  128. ch4:=pos('align="',t[9])+7;
  129. insert(ch6,t[9],ch4);
  130. writeln('donner votre text');
  131. readln(ch8);
  132. ch7:=pos('>',t[9])+1;
  133. insert(ch8,t[9],ch7);
  134. end;
  135.  
  136. procedure input (var t:tab);
  137. var
  138. in7,in6,in4,in2,repinput,fo1,fo2:string;
  139. in8,in5,in3,in1,i,inp:integer;
  140.    begin
  141.  
  142. writeln('donner le nombre d''input');
  143. readln(inp);
  144. fo1:='<form method="POST" action=".php" name="f" onsubmit="return verif1()">';
  145. fo2:='</form>';
  146.   for i:=1 to inp do
  147.    begin
  148.  
  149. insert('<input type="" name="" align="">',t[10],length(t[10])+1);
  150. writeln('tu veux ret ou ligne (oui/non) input[',i,']');
  151. readln(repinput);
  152.  
  153.   if (repinput = 'oui') then
  154.    begin
  155.  
  156. insert('<br />',t[10],length(t[10])+1);
  157.    end;
  158.  
  159. writeln('donner le type d''input (text/password) [',i,']');
  160. readln(in2);
  161. in1:=pos('type=""',t[10])+6;
  162. insert(in2,t[10],in1);
  163.  writeln('donner align');
  164.  readln(in6);
  165.  in5:=pos('align=""',t[10])+7;
  166.  insert(in6,t[10],in5);
  167. writeln('donner le nom du forme');
  168. readln(in7);
  169. in8:=pos('name=""',t[10])+6;
  170. insert(in7,t[10],in8);
  171.  
  172. end;
  173. t[11]:=fo1+t[10]+fo2;
  174. end;
  175.  
  176. procedure areaf (var t:tab);
  177. var
  178. area3,area2,area:string;
  179. area4,area1:integer;
  180.  
  181. begin
  182. t[12]:='<textarea rows="" cols=""></textarea>';
  183. writeln('donner les rows');
  184. readln(area2);
  185. area1:=pos('""',t[12])+1;
  186. insert(area2,t[12],area1);
  187. writeln('donner les cols');
  188. readln(area3);
  189. area4:=pos('>',t[12])-1;
  190. insert(area3,t[12],area4);
  191. end;
  192. procedure cre (var f:text;var reponse:integer);
  193. begin
  194. writeln('                             __  .__               ');
  195. writeln('  ___________   ____ _____ _/  |_|__| ____   ____  ');
  196. writeln(' / ___\_  __ \_/ __ \\__  \\   __\  |/  _ \ /    \ ');
  197. writeln('\  \___|  | \/\  ___/ / __ \|  | |  (  <_> )   |  \');
  198. writeln(' \___  >__|    \___  >____  /__| |__|\____/|___|  /');
  199. writeln('     \/            \/     \/                    \/ ');
  200. repeat
  201. writeln('donner votre choix || (tu peux sortie si tu tape 0)');
  202. writeln('background(1)'); writeln('title(2)');writeln('icon(3)');writeln('script(4)');writeln('h(5)');writeln('input(6)');
  203. writeln('areaf');
  204. writeln('reponse:');
  205. readln(reponse);
  206. clrscr;
  207. case reponse of
  208.  
  209. 1:background(t);
  210. 2:title(t);
  211. 3:icon(t);
  212. 4:script(t);
  213. 5:h(t);
  214. 6:input(t);
  215. 7:areaf(t);
  216. end;
  217. until reponse=0;
  218. end;
  219. procedure remplirefinal (var f:text;t:tab);
  220.   var
  221.   chx:string;
  222.   j:integer;
  223.   begin
  224. rewrite(f);
  225.     for j:=1 to 12 do
  226.     begin
  227. writeln(f,t[j]);
  228.   end;
  229.   end;
  230. begin
  231. assign(f,'C:\tpw\4.txt');
  232. bodyf(t);
  233. cre(f,reponse);
  234. remplirehtml(t);
  235. close(f);
  236. end.
  237.  

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5251
So what problem is it?

whitehat

  • Jr. Member
  • **
  • Posts: 51
the problem is in the procedure of input when i finesh the work this is the result:
when i chose to create 2 input form the first is for login (text); and the second is for the password
i was surprise of the result there's 4 input 2 inside the <form></form> and tow Outside the <form> tag like the example :
Code: Pascal  [Select]
  1. <html>
  2. <head>
  3. <link rel="stylesheet" href="jpg">
  4. <title>hello again</title>
  5. <style> input[type=text], input[type=password] {width: 50%;padding: 12px 20px;margin: 8px 0;box-sizing: border-box;border: 2px solid red;border-radius: 4px;float: right;}</style>
  6. </head>
  7. <body background="">
  8. <body bgcolor="black">
  9. <h4 align="left" style="color:red;">hello test</h4>
  10. <input type="text" name="f" align="center"><br /><input type="text" name="f2" align="center" >
  11. <form method="POST" action=".php" name="f" onsubmit="return verif1()"><input type="text" name="f" align="center"><br /><input type="text" name="f2" align="center" ><br /></form>
  12. </body>
  13. </html>
  14.  
and here's the procedure of input for creation the form :
Code: Pascal  [Select]
  1. procedure input (var t:tab);
  2. var
  3. in7,in6,in4,in2,repinput,fo1,fo2:string;
  4. in8,in5,in3,in1,i,inp:integer;
  5.    begin
  6.  
  7. writeln('donner le nombre d''input');
  8. readln(inp);
  9. fo1:='<form method="POST" action=".php" name="f" onsubmit="return verif1()">';
  10. fo2:='</form>';
  11.   for i:=1 to inp do
  12.    begin
  13.  
  14. insert('<input type="" name="" align="">',t[10],length(t[10])+1);
  15. writeln('tu veux ret ou ligne (oui/non) input[',i,']');
  16. readln(repinput);
  17.  
  18.   if (repinput = 'oui') then
  19.    begin
  20.  
  21. insert('<br />',t[10],length(t[10])+1);
  22.    end;
  23.  
  24. writeln('donner le type d''input (text/password) [',i,']');
  25. readln(in2);
  26. in1:=pos('type=""',t[10])+6;
  27. insert(in2,t[10],in1);
  28.  writeln('donner align');
  29.  readln(in6);
  30.  in5:=pos('align=""',t[10])+7;
  31.  insert(in6,t[10],in5);
  32. writeln('donner le nom du forme');
  33. readln(in7);
  34. in8:=pos('name=""',t[10])+6;
  35. insert(in7,t[10],in8);
  36.  
  37. end;
  38. t[11]:=fo1+t[10]+fo2;
  39. end;
  40.  

Handoko

  • Hero Member
  • *****
  • Posts: 877
  • My goal: build my own game engine using Lazarus
Because I'm not good in HTML and my Linux Lazarus/FPC can't run WinCRT properly, I can only rely on my eye-inspection.

You should change your code line 173 from:
Quote
t[11]:=fo1+t[10]+fo2;

To:
Quote
t[10]:=fo1+t[10]+fo2;

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus