Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program DataBaseManipulator;
- const
- nmax=10;
- var
- i,e,n:integer;
- a:array [1..nmax] of string;
- blabla:text;
- k:integer;
- VAR strInput:STRING;
- function CreateDatabaseString(var strResult:string):boolean;
- {====variables=======}
- VAR strID:STRING;
- VAR strCompany:STRING;
- VAR strSeller:STRING;
- VAR strCost:STRING;
- VAR strAge:STRING;
- i:integer;
- var arrStr : array [1..5] of string;
- temp:STRING;
- wasRemoved:BOOLEAN;
- {=========================================================================}
- function REMOVEDELIMETER(VAR STR:STRING):BOOLEAN;
- var h:set of char; s,temp:string;i:byte;
- BEGIN
- REMOVEDELIMETER:=TRUE;
- temp:='';
- h:=[];
- h:=['À'..'ß','à'..'ÿ','A'..'Z','a'..'z','0'..'9']; (*numbers and letters*)
- s:=STR;
- for i:=1 to length(s) do begin
- if (s[i] in h) then temp:=concat(temp,s[i]);
- end;
- STR:=temp
- END;
- {=========================================================================}
- function REMOVEDELIMETERANDLETTERS(VAR STR:STRING):BOOLEAN;
- var h:set of char; s,temp:string;i:byte;
- BEGIN
- REMOVEDELIMETERANDLETTERS:=TRUE;
- temp:='';
- h:=[];
- h:=['0'..'9']; (*just numbers*)
- s:=STR;
- for i:=1 to length(s) do
- begin
- if (s[i] in h) then
- begin
- temp:=concat(temp,s[i]);
- end;
- end;
- if(length(s)>length(temp)) then REMOVEDELIMETERANDLETTERS:=FALSE;
- STR:=temp
- END;
- {=========================================================================}
- BEGIN
- {===strID=====}
- repeat
- write('Please enter an id of product (string without letters and symbols): ');
- readln(arrStr[1]);
- wasRemoved:=REMOVEDELIMETERANDLETTERS(arrStr[1]);
- until wasRemoved=TRUE;
- {===strCompany=====}
- write('Please enter a company name: ');
- readln(arrStr[2]);
- REMOVEDELIMETER(arrStr[2]);
- {===strSeller=====}
- write('Please enter a seller name: ');
- readln(arrStr[3]);
- REMOVEDELIMETER(arrStr[3]);
- {===strCost=====}
- repeat
- write('Please enter an amount of money of product (string without letters and symbols): ');
- readln(arrStr[4]);
- wasRemoved:=REMOVEDELIMETERANDLETTERS(arrStr[4]);
- until wasRemoved=TRUE;
- {===strAge=====}
- repeat
- write('Please enter an age (string without letters and symbols): ');
- readln(arrStr[5]);
- wasRemoved:=REMOVEDELIMETERANDLETTERS(arrStr[5]);
- until wasRemoved=TRUE;
- strResult:='';
- temp:='';
- for i:=1 to 5 do
- begin
- temp:=concat(arrStr[i],'-');
- strResult:=concat(strResult,temp);
- temp:='';
- end;
- delete(strResult,length(strResult),1);
- END;
- Procedure Menu;
- var vibor:integer;
- begin
- writeln('âûáåðèòå äåéñòâèå');
- writeln('1-çàïèñü ñòðîêè');
- writeln('2-âûâîä äàííûõ');
- writeln('3-ðåäàêòèðîâàíèå');
- readln(vibor);
- case vibor of
- 1:CreateDatabaseString(strInput);
- end;
- end;
- {=========================================================================}
- BEGIN
- Menu;
- END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement