n

- Rejestracja:prawie 17 lat
- Ostatnio:około 3 lata
- Lokalizacja:Szczecin
- Postów:4191
2
Powinieneś najpierw poznać podstawy. Przejrzystość kodu, nazywanie zmiennej iteracyjnej "a" co kojarzy się bardziej z tablicą i inne "cyrki". Ogólnie dramat.
"Ciekawy" pomysł to też ponad 915696383431337 parametrów funkcji, zamiast jakiejś tablicy.
Poniżej masz poprawiony kod tak, aby w ogóle się pod FPC kompilował. Nie wnikam w prawidłowość działania i dwa warningi, które i tak wystepują. To już popraw samodzielnie.
program testsprawnosci;
{$MODE DELPHI}
uses
crt;
function WriteInTabUserPassword(UserPassword : string; ResetShadowChar : Byte; Sw1 : Byte; Sw16 : Byte; Sw2 : Byte; Sw17 : Byte; Sw3 : Byte; Sw18 : Byte; Sw4 : Byte; Sw19 : Byte; Sw5 : Byte; Sw20 : Byte; Sw6 : Byte; Sw21 : Byte; Sw7 : Byte; Sw22 : Byte; Sw8 : Byte; Sw23 : Byte; Sw9 : Byte; Sw24 : Byte; Sw10 : Byte; Sw25 : Byte; Sw11 : Byte; Sw26 : Byte; Sw12 : Byte; Sw27 : Byte; Sw13 : Byte; Sw28 : Byte; Sw14 : Byte; Sw29 : Byte; Sw15 : Byte; Sw30 : Byte) : string;
//Do Funkcji należy podać UserPassword czyli zaszyfrowane hasło, ResetShadowChar czyli czy ma być resetowana tablica danych do zmyłki, kolejno współrzędne liter hasła w tablicy x =Sw1 y=Sw16, x=Sw2 y=Sw17 ...
var
TabC0de : array[1..20, 1..20] of byte;
var
TabC0deInPass : array[1..30] of byte;
var
UserPasswordCodedTab : array[1..15] of byte;
var
UserPasswordCodedTabChar : array[1..15] of Char;
var
a, b, c, d, e, f, g : byte;
begin
randomize; // Ustawianie randomowych liczb
if ResetShadowChar = 1 then // Jeżeli ResetShadowChar
begin
for a := 1 to 20 do // Wypelnienie tablicy losowymi liczbami
begin
for b := 1 to 20 do
begin
TabC0de[a, b] := random(255);
end;
end; //END Wypelnienie tablicy losowymi liczbami
ResetShadowChar := 0;
end;
for c := 1 to 15 do
UserPasswordCodedTabChar[c] := UserPassword[c]; // Zamiana String na Char
for d := 1 to 15 do // Zamiana znaków Char na Liczby
begin
UserPasswordCodedTab[d] := ord(UserPasswordCodedTabChar[d]);
end;
TabC0deInPass[1] := Sw1;
TabC0deInPass[16] := Sw16; // Współrzędne liter hasła do wpisania w tablice
TabC0deInPass[2] := Sw2;
TabC0deInPass[17] := Sw17;
TabC0deInPass[3] := Sw3;
TabC0deInPass[18] := Sw18;
TabC0deInPass[4] := Sw4;
TabC0deInPass[19] := Sw19;
TabC0deInPass[5] := Sw5;
TabC0deInPass[20] := Sw20;
TabC0deInPass[6] := Sw6;
TabC0deInPass[21] := Sw21;
TabC0deInPass[7] := Sw7;
TabC0deInPass[22] := Sw22;
TabC0deInPass[8] := Sw8;
TabC0deInPass[23] := Sw23;
TabC0deInPass[9] := Sw9;
TabC0deInPass[24] := Sw24;
TabC0deInPass[10] := Sw10;
TabC0deInPass[25] := Sw25;
TabC0deInPass[11] := Sw11;
TabC0deInPass[26] := Sw26;
TabC0deInPass[12] := Sw12;
TabC0deInPass[27] := Sw27;
TabC0deInPass[13] := Sw13;
TabC0deInPass[28] := Sw28;
TabC0deInPass[14] := Sw14;
TabC0deInPass[29] := Sw29;
TabC0deInPass[15] := Sw15;
TabC0deInPass[30] := Sw30;
for e := 1 to 15 do // Wpisywanie w tablice liter hasła
begin
TabC0de[TabC0deInPass[e], TabC0deInPass[e + 15]] := UserPasswordCodedTab[e];
end;
Result := '';
for f := 1 to 20 do // Zastapienie losowych liczb znakami kodu ASCII
begin
for g := 1 to 20 do
begin
Result := Result + Chr(TabC0de[f, g]);
end;
end; //END Zastapienie losowych liczb znakami kodu ASCII
end; // Koniec Funkcji WriteInTabUserPassword
function ReadInTabUserPassword(Sw1 : Byte; Sw16 : Byte; Sw2 : Byte; Sw17 : Byte; Sw3 : Byte; Sw18 : Byte; Sw4 : Byte; Sw19 : Byte; Sw5 : Byte; Sw20 : Byte; Sw6 : Byte; Sw21 : Byte; Sw7 : Byte; Sw22 : Byte; Sw8 : Byte; Sw23 : Byte; Sw9 : Byte; Sw24 : Byte; Sw10 : Byte; Sw25 : Byte; Sw11 : Byte; Sw26 : Byte; Sw12 : Byte; Sw27 : Byte; Sw13 : Byte; Sw28 : Byte; Sw14 : Byte; Sw29 : Byte; Sw15 : Byte; Sw30 : Byte) : string;
//Do Funkcji należy podać, kolejno współrzędne liter hasła w tablicy x =Sw1 y=Sw16, x=Sw2 y=Sw17 ...
var
TabC0de : array[1..20, 1..20] of byte;
TabC0deInPass : array[1..30] of byte;
a : byte;
begin
ReadInTabUserPassword := '';
TabC0deInPass[1] := Sw1;
TabC0deInPass[16] := Sw16; // Współrzędne liter hasła w tablice
TabC0deInPass[2] := Sw2;
TabC0deInPass[17] := Sw17;
TabC0deInPass[3] := Sw3;
TabC0deInPass[18] := Sw18;
TabC0deInPass[4] := Sw4;
TabC0deInPass[19] := Sw19;
TabC0deInPass[5] := Sw5;
TabC0deInPass[20] := Sw20;
TabC0deInPass[6] := Sw6;
TabC0deInPass[21] := Sw21;
TabC0deInPass[7] := Sw7;
TabC0deInPass[22] := Sw22;
TabC0deInPass[8] := Sw8;
TabC0deInPass[23] := Sw23;
TabC0deInPass[9] := Sw9;
TabC0deInPass[24] := Sw24;
TabC0deInPass[10] := Sw10;
TabC0deInPass[25] := Sw25;
TabC0deInPass[11] := Sw11;
TabC0deInPass[26] := Sw26;
TabC0deInPass[12] := Sw12;
TabC0deInPass[27] := Sw27;
TabC0deInPass[13] := Sw13;
TabC0deInPass[28] := Sw28;
TabC0deInPass[14] := Sw14;
TabC0deInPass[29] := Sw29;
TabC0deInPass[15] := Sw15;
TabC0deInPass[30] := Sw30;
Result := '';
for a := 1 to 15 do // Wyciąganie Hasła z Tabeli
begin
Result := Result + Chr(TabC0de[a][a + 15]);
end;
end; // Koniec Funkcji ReadInTabUserPassword
begin
WriteInTabUserPassword('MICHAŁaaaaaaaaa', 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1);
Writeln;
Writeln;
Writeln('Odczytano: ', ReadInTabUserPassword(1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1));
Readln;
end.
edytowany 1x, ostatnio: olesio
- Rejestracja:prawie 12 lat
- Ostatnio:około 6 lat
- Postów:220
1
lap sformatowany kod z zakomentowaniem kodu gdzie wywala blad podczas kompilacji
program testsprawnosci;
uses crt;
function WriteInTabUserPassword(UserPassword: string; ResetShadowChar: Byte;
Sw1: Byte; Sw16: Byte; Sw2: Byte; Sw17: Byte; Sw3: Byte;
Sw18: Byte; Sw4: Byte; Sw19: Byte; Sw5: Byte; Sw20: Byte; Sw6: Byte; Sw21:
Byte; Sw7: Byte; Sw22: Byte; Sw8: Byte; Sw23: Byte; Sw9: Byte;
Sw24: Byte; Sw10: Byte; Sw25: Byte; Sw11: Byte; Sw26: Byte; Sw12: Byte; Sw27:
Byte; Sw13: Byte; Sw28: Byte; Sw14: Byte; Sw29: Byte;
Sw15: Byte; Sw30: Byte): string;
// Do Funkcji należy podać UserPassword czyli zaszyfrowane hasło, ResetShadowChar czyli czy ma być resetowana tablica danych do zmyłki, kolejno współrzędne liter hasła w tablicy x =Sw1 y=Sw16, x=Sw2 y=Sw17 ...
var
TabC0de: array[1..20, 1..20] of Byte;
var
TabC0deInPass: array[1..30] of Byte;
var
UserPasswordCodedTab: array[1..15] of Byte;
var
UserPasswordCodedTabChar: array[1..15] of Char;
var
a, b, c, d, e, f, g: Byte;
begin
randomize; // Ustawianie randomowych liczb
if ResetShadowChar = 1 then // Jeżeli ResetShadowChar
begin
for a := 1 to 20 do // Wypelnienie tablicy losowymi liczbami
begin
for b := 1 to 20 do
begin
TabC0de[a, b] := random(255);
end;
end; // END Wypelnienie tablicy losowymi liczbami
ResetShadowChar := 0;
end;
for c := 1 to 15 do
UserPasswordCodedTabChar[c] := UserPassword[c]; // Zamiana String na Char
for d := 1 to 15 do // Zamiana znaków Char na Liczby
begin
UserPasswordCodedTab[d] := ord(UserPasswordCodedTabChar[d]);
end;
TabC0deInPass[1] := Sw1;
TabC0deInPass[16] := Sw16; // Współrzędne liter hasła do wpisania w tablice
TabC0deInPass[2] := Sw2;
TabC0deInPass[17] := Sw17;
TabC0deInPass[3] := Sw3;
TabC0deInPass[18] := Sw18;
TabC0deInPass[4] := Sw4;
TabC0deInPass[19] := Sw19;
TabC0deInPass[5] := Sw5;
TabC0deInPass[20] := Sw20;
TabC0deInPass[6] := Sw6;
TabC0deInPass[21] := Sw21;
TabC0deInPass[7] := Sw7;
TabC0deInPass[22] := Sw22;
TabC0deInPass[8] := Sw8;
TabC0deInPass[23] := Sw23;
TabC0deInPass[9] := Sw9;
TabC0deInPass[24] := Sw24;
TabC0deInPass[10] := Sw10;
TabC0deInPass[25] := Sw25;
TabC0deInPass[11] := Sw11;
TabC0deInPass[26] := Sw26;
TabC0deInPass[12] := Sw12;
TabC0deInPass[27] := Sw27;
TabC0deInPass[13] := Sw13;
TabC0deInPass[28] := Sw28;
TabC0deInPass[14] := Sw14;
TabC0deInPass[29] := Sw29;
TabC0deInPass[15] := Sw15;
TabC0deInPass[30] := Sw30;
for e := 1 to 15 do // Wpisywanie w tablice liter hasła
begin
TabC0de[TabC0deInPass[e], TabC0deInPass[e + 15]] := UserPasswordCodedTab[e];
end;
for f := 1 to 20 do // Zastapienie losowych liczb znakami kodu ASCII
begin
for g := 1 to 20 do
begin
// writeInTabUserPassword := writeInTabUserPasswor + chr(TabC0de[f,g]);
end;
end; // END Zastapienie losowych liczb znakami kodu ASCII
end; // Koniec Funkcji WriteInTabUserPassword
function ReadInTabUserPassword(Sw1: Byte; Sw16: Byte; Sw2: Byte; Sw17: Byte;
Sw3: Byte; Sw18: Byte; Sw4: Byte; Sw19: Byte; Sw5: Byte;
Sw20: Byte; Sw6: Byte; Sw21: Byte; Sw7: Byte; Sw22: Byte; Sw8: Byte; Sw23:
Byte; Sw9: Byte; Sw24: Byte; Sw10: Byte; Sw25: Byte;
Sw11: Byte; Sw26: Byte; Sw12: Byte; Sw27: Byte; Sw13: Byte; Sw28: Byte; Sw14:
Byte; Sw29: Byte; Sw15: Byte; Sw30: Byte): string;
// Do Funkcji należy podać, kolejno współrzędne liter hasła w tablicy x =Sw1 y=Sw16, x=Sw2 y=Sw17 ...
var
TabC0de: array[1..20, 1..20] of Byte;
var
TabC0deInPass: array[1..30] of Byte;
var
a: Byte;
begin
ReadInTabUserPassword := '';
TabC0deInPass[1] := Sw1;
TabC0deInPass[16] := Sw16; // Współrzędne liter hasła w tablice
TabC0deInPass[2] := Sw2;
TabC0deInPass[17] := Sw17;
TabC0deInPass[3] := Sw3;
TabC0deInPass[18] := Sw18;
TabC0deInPass[4] := Sw4;
TabC0deInPass[19] := Sw19;
TabC0deInPass[5] := Sw5;
TabC0deInPass[20] := Sw20;
TabC0deInPass[6] := Sw6;
TabC0deInPass[21] := Sw21;
TabC0deInPass[7] := Sw7;
TabC0deInPass[22] := Sw22;
TabC0deInPass[8] := Sw8;
TabC0deInPass[23] := Sw23;
TabC0deInPass[9] := Sw9;
TabC0deInPass[24] := Sw24;
TabC0deInPass[10] := Sw10;
TabC0deInPass[25] := Sw25;
TabC0deInPass[11] := Sw11;
TabC0deInPass[26] := Sw26;
TabC0deInPass[12] := Sw12;
TabC0deInPass[27] := Sw27;
TabC0deInPass[13] := Sw13;
TabC0deInPass[28] := Sw28;
TabC0deInPass[14] := Sw14;
TabC0deInPass[29] := Sw29;
TabC0deInPass[15] := Sw15;
TabC0deInPass[30] := Sw30;
for a := 1 to 15 do // Wyciąganie Hasła z Tabeli
begin
// ReadInTabUserPassword := ReadInTabUserPassword + TabC0de[TabC0deInPass[a],TabC0deInPass[a+15]];
end;
end; // Koniec Funkcji ReadInTabUserPassword
begin
WriteInTabUserPassword('MICHAŁaaaaaaaaa', 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6,
1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14,
1, 15, 1);
// Writeln(WriteInTabUserPassword); writeln;writeln;
Writeln('Odczytano: ', ReadInTabUserPassword(1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6,
1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14,
1, 15, 1));
readln;
end.
- Rejestracja:ponad 14 lat
- Ostatnio:około 10 godzin
1
W linii piątej , po ostatnim parametrze liście parametrów funkcji , jest nadmiarowy średnik.
"Sw30:Byte;)"
a tutaj :
writeInTabUserPassword := writeInTabUserPasswor + chr(TabC0de[f,g]);
'writeInTabUserPassword' zadeklarowałeś wcześniej jako funkcję
a jest jeszcze wiele innych błędów składniowych w kodzie ....