Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.41 KB | None | 0 0
  1. program DataBaseManipulator;
  2. const
  3. nmax=10;
  4. var
  5. i,e,n:integer;
  6. a:array [1..nmax] of string;
  7. blabla:text;
  8. k:integer;
  9.  
  10. VAR strInput:STRING;
  11.  
  12.  
  13.  
  14.   function CreateDatabaseString(var strResult:string):boolean;
  15.   {====variables=======}
  16.     VAR strID:STRING;
  17.     VAR strCompany:STRING;
  18.     VAR strSeller:STRING;
  19.     VAR strCost:STRING;
  20.     VAR strAge:STRING;
  21.     i:integer;
  22.     var arrStr : array [1..5] of string;
  23.     temp:STRING;
  24.     wasRemoved:BOOLEAN;
  25.   {=========================================================================}
  26.     function REMOVEDELIMETER(VAR STR:STRING):BOOLEAN;
  27.       var h:set of char; s,temp:string;i:byte;
  28.         BEGIN
  29.           REMOVEDELIMETER:=TRUE;
  30.            temp:='';
  31.            h:=[];
  32.            h:=['À'..'ß','à'..'ÿ','A'..'Z','a'..'z','0'..'9']; (*numbers and letters*)
  33.            s:=STR;
  34.            for i:=1 to length(s) do begin
  35.                if (s[i] in h) then temp:=concat(temp,s[i]);
  36.            end;
  37.            STR:=temp
  38.         END;
  39.   {=========================================================================}
  40.     function REMOVEDELIMETERANDLETTERS(VAR STR:STRING):BOOLEAN;
  41.       var h:set of char; s,temp:string;i:byte;
  42.         BEGIN
  43.           REMOVEDELIMETERANDLETTERS:=TRUE;
  44.            temp:='';
  45.            h:=[];
  46.            h:=['0'..'9']; (*just numbers*)
  47.            s:=STR;
  48.            for i:=1 to length(s) do
  49.            begin
  50.                if (s[i] in h) then
  51.                 begin
  52.                 temp:=concat(temp,s[i]);
  53.                 end;
  54.            end;
  55.            if(length(s)>length(temp)) then REMOVEDELIMETERANDLETTERS:=FALSE;
  56.            STR:=temp
  57.         END;
  58.   {=========================================================================}
  59.     BEGIN
  60.       {===strID=====}
  61.       repeat
  62.         write('Please enter an id of product (string without letters and symbols): ');
  63.         readln(arrStr[1]);
  64.         wasRemoved:=REMOVEDELIMETERANDLETTERS(arrStr[1]);
  65.       until wasRemoved=TRUE;
  66.       {===strCompany=====}
  67.         write('Please enter a company name: ');
  68.         readln(arrStr[2]);
  69.         REMOVEDELIMETER(arrStr[2]);
  70.       {===strSeller=====}
  71.         write('Please enter a seller name: ');
  72.         readln(arrStr[3]);
  73.         REMOVEDELIMETER(arrStr[3]);
  74.       {===strCost=====}
  75.       repeat
  76.         write('Please enter an amount of money of product (string without letters and symbols): ');
  77.         readln(arrStr[4]);
  78.         wasRemoved:=REMOVEDELIMETERANDLETTERS(arrStr[4]);
  79.       until wasRemoved=TRUE;
  80.       {===strAge=====}
  81.       repeat
  82.         write('Please enter an age (string without letters and symbols): ');
  83.         readln(arrStr[5]);
  84.         wasRemoved:=REMOVEDELIMETERANDLETTERS(arrStr[5]);
  85.       until wasRemoved=TRUE;
  86.  
  87.     strResult:='';
  88.     temp:='';
  89.     for i:=1 to 5 do
  90.     begin
  91.          temp:=concat(arrStr[i],'-');
  92.          strResult:=concat(strResult,temp);
  93.          temp:='';
  94.     end;
  95.     delete(strResult,length(strResult),1);
  96.  
  97.   END;
  98.  
  99.   Procedure Menu;
  100.   var vibor:integer;
  101.   begin
  102.  
  103.      writeln('âûáåðèòå äåéñòâèå');
  104.         writeln('1-çàïèñü ñòðîêè');
  105.         writeln('2-âûâîä äàííûõ');
  106.         writeln('3-ðåäàêòèðîâàíèå');
  107.      readln(vibor);
  108.  
  109.     case vibor of
  110.      1:CreateDatabaseString(strInput);
  111.  
  112.   end;
  113.   end;
  114.  
  115.  
  116.  
  117.   {=========================================================================}
  118. BEGIN
  119.   Menu;
  120.  
  121.  
  122. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement