Page 2 of 2 FirstFirst 12
Results 26 to 36 of 36

Thread: Dg's Small Procedures

  1. #26
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by Blumblebee View Post
    Are you sure that would work? You deal with the string like it's an array which I didn't think was possible...
    Why wouldn't it work? After all, a string is just an array of chars.
    There used to be something meaningful here.

  2. #27
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    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.

  3. #28
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    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.

    Code:
    Compiled succesfully in 15 ms.
    Wf|#!
    Successfully executed.
    Works for me.
    There used to be something meaningful here.

  4. #29
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    wat

    Swore it gave me an error before..

    Either way, mine was a single line shorter. :3

  5. #30
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    cool, you learn something new everyday haha

  6. #31
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    wat

    Swore it gave me an error before..

    Either way, mine was a single line shorter. :3
    hopes that pascal strings are mutable
    Interested in C# and Electrical Engineering? This might interest you.

  7. #32
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    wat

    Swore it gave me an error before..

    Either way, mine was a single line shorter. :3
    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.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  8. #33
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    I know.

    It makes sense, I'm just confus on why I thought it didn't work before.

  9. #34
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,193
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    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."

  10. #35
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by BraK View Post
    Moved as requested/also part of the cleaning up of tutorial Island.

    ~BraK
    Thanks =) New Section? Didn't see it before.

    Gonna be adding more to it soon.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  11. #36
    Join Date
    May 2012
    Location
    Wisconsin, USA
    Posts
    105
    Mentioned
    1 Post(s)
    Quoted
    47 Post(s)

    Default

    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?

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •