But in practical use, it interprets it as a literal array of chars, and not as a string, so it gives you a type mismatch.
Simba Code:program new;
function RandomKey(Len: integer): string;
var
I: integer;
begin
SetLength(Result, Len);
for I := 1 to Len do
Result[I] := chr(33 + Random(93));
end;
begin
Writeln(RandomKey(5));
end.
Works for me.Code:Compiled succesfully in 15 ms. Wf|#! Successfully executed.
There used to be something meaningful here.
wat
Swore it gave me an error before..
Either way, mine was a single line shorter. :3
cool, you learn something new everyday haha
Interested in C# and Electrical Engineering? This might interest you.
Nope Try this
Simba Code:program new;
{*******************************************************************************
function RandomKey(Len: integer): string;
By: Dgby714, Sandstorm, Smartzkid
Description: Returns a random string with Len Length
*******************************************************************************}
function RandomKey(Len: Integer): string;
var
i: Integer;
begin
for i := 0 to Len - 1 do
Result := Result + chr(33 + Random(93));
end;
var
Test: string;
begin
Test := 'Dgby714 rocks * '
Test := RandomKey(12);
WriteLn(Test);
end.
Output:
Code:Compiled succesfully in 16 ms. Dgby714 rocks * qDpmw:/pFMmJ Successfully executed.
I know.
It makes sense, I'm just confus on why I thought it didn't work before.
Moved as requested/also part of the cleaning up of tutorial Island.
~BraK
"Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."
I know this is a very old thread, but @Dgby, have you put all these funcs into a single file so they can be used as an include?
There are currently 1 users browsing this thread. (0 members and 1 guests)