Results 1 to 17 of 17

Thread: Name to Number

  1. #1
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Name to Number

    I made this more of a fun script...

    Please report any problems and post your number!

    SCAR Code:
    program NametoNumber;
    //Made by Smithsps

    var
    Name, LetterChar, TotalStr, NameLengthStr, Exit1, Alpha : string;
    NameLength, Total, NameNum, NameNum1, Calc : integer;
    A : array of string;
    B : array of integer;

    procedure Report;
    begin
       TotalStr := inttostr(Total);
       NameLengthStr := inttostr(NameLength);
       writeln('Your number is: ' + TotalStr);
       writeln('');
       writeln('Made by smithsps');
       writeln('');
    end;

    procedure Calculation;
    begin
       LetterChar := copy(Name, NameNum, NameNum1);
       Alpha := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890';
       for Calc := 1 to NameLength do
          if(pos(LetterChar, Alpha) > 0) then
             Total := Total + B[pos(LetterChar, Alpha) - 1];
    end;

    procedure Entry;
    begin
       ClearDebug;
       Name := readln('What is your name?');
       Name := uppercase(name);
       NameLength := Length(Name);
       NameNum := 0
       NameNum1 := 1
       Total := 0;
    end;

    procedure DeclareArray;
    begin
       setarraylength(A, 37);
       A := ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
       'M', 'N', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
       ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
    //////////////////////////////////
       setarraylength(B,37);
       B :=[13, 14, 70, 55, 41, 98, 73, 59, 20, 5, 47, 59, 52, 76, 37, 2, 83,
       33, 95, 56, 12, 74, 82, 87, 64, 69, 0, 48, 35, 57, 22, 67, 40, 96, 54, 15, 67];
    end;


    begin
       DeclareArray;
       repeat
          Entry;
          Calculation;
          Report;
          Exit1 := readln('Would you like to quit? Y/N');
       until(Exit1 = 'y') or (Exit1 = 'Y');
    end.

    I also used a random number generator to help.

    SCAR Code:
    program RandomNumberGenerator;

    const
    B = 100; //Maxium random number.
    D = 10; //How many random numbers you need.

    var
    A, C : integer;
    E : string;

    begin
       C := 0;
       ClearDebug;
       repeat
          wait(50); // Adds to the effect. :)
          A := random(B) + 1;
          E := inttostr(A);
          writeln(E);
          C := C + 1;
       until(D = C);
    end.

  2. #2
    Join Date
    Sep 2007
    Location
    Pennsylvania
    Posts
    3,396
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Your number is: 1008

    (First + Last)

    I was hoping it'd be 1337

    Pretty decent script

  3. #3
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Your number is: 413

    Made by smithsps

    Successfully executed
    Pretty cool I guess


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  4. #4
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Does any one have any suggestions? I can always improve.(h)



    Edit: Script Updated to include numbers.

  5. #5
    Join Date
    Dec 2007
    Location
    Michigan, USA
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    procedure Calculation;
    begin
       LetterChar := copy(Name, NameNum, NameNum1);
       repeat
          if (LetterChar = 'A') then
             Total := Total + B[0];
          if (LetterChar = 'B') then
             Total := Total + B[1];
          if (LetterChar = 'C') then
             Total := Total + B[2];
          if (LetterChar = 'D') then
             Total := Total + B[3];
          if (LetterChar = 'E') then
             Total := Total + B[4];
          if (LetterChar = 'F') then
             Total := Total + B[5];
          if (LetterChar = 'G') then
             Total := Total + B[6];
          if (LetterChar = 'H') then
             Total := Total + B[7];
          if (LetterChar = 'I') then
             Total := Total + B[8];
          if (LetterChar = 'J') then
             Total := Total + B[9];
          if (LetterChar = 'K') then
             Total := Total + B[10];
          if (LetterChar = 'L') then
             Total := Total + B[11];
          if (LetterChar = 'M') then
             Total := Total + B[12];
          if (LetterChar = 'N') then
             Total := Total + B[13];
          if (LetterChar = 'O') then
             Total := Total + B[14];
          if (LetterChar = 'P') then
             Total := Total + B[15];
          if (LetterChar = 'Q') then
             Total := Total + B[16];
          if (LetterChar = 'R') then
             Total := Total + B[17];
          if (LetterChar = 'S') then
             Total := Total + B[18];
          if (LetterChar = 'T') then
             Total := Total + B[19];
          if (LetterChar = 'U') then
             Total := Total + B[20];
          if (LetterChar = 'V') then
             Total := Total + B[21];
          if (LetterChar = 'W') then
             Total := Total + B[22];
          if (LetterChar = 'X') then
             Total := Total + B[23];
          if (LetterChar = 'Y') then
             Total := Total + B[24];
          if (LetterChar = 'Z') then
             Total := Total + B[25];
          if (LetterChar = ' ') then
             Total := Total + B[26];
          if (LetterChar = '1') then
             Total := Total + B[27];
          if (LetterChar = '2') then
             Total := Total + B[28];
          if (LetterChar = '3') tHen
             Total := Total + B[29];
          if (LetterChar = '4') then
             Total := Total + B[30];
          if (LetterChar = '5') then
             Total := Total + B[31];
          if (LetterChar = '6') then
             Total := Total + B[32];
          if (LetterChar = '7') then
             Total := Total + B[33];
          if (LetterChar = '8') then
             Total := Total + B[34];
          if (LetterChar = '9') then
             Total := Total + B[35];
          if (LetterChar = '10') then
             Total := Total + B[36];
          if (LetterChar = '0') then
             Total := Total + B[37];
          NameNum := NameNum + 1;
       until (NameNum = NameLength);
    end;
    ^this should be this:
    SCAR Code:
    procedure Calculation;
    begin
       LetterChar := copy(Name, NameNum, NameNum1);
       repeat
          case lowercase(LetterChar) of
            'a': Total := Total + B[0];
            'b': Total := Total + B[1];
            'b': Total := Total + B[2];
            'd': Total := Total + B[3];
            'e': Total := Total + B[4];
            'f': Total := Total + B[5];
            'g': Total := Total + B[6];
            'h': Total := Total + B[7];
            'i': Total := Total + B[8];
            'j': Total := Total + B[9];
            'k': Total := Total + B[10];
            'l': Total := Total + B[11];
            'm': Total := Total + B[12];
            'n': Total := Total + B[13];
            'o': Total := Total + B[14];
            'p': Total := Total + B[15];
            'q': Total := Total + B[16];
            'r': Total := Total + B[17];
            's': Total := Total + B[18];
            't': Total := Total + B[19];
            'u': Total := Total + B[20];
            'v': Total := Total + B[21];
            'w': Total := Total + B[22];
            'x': Total := Total + B[23];
            'y': Total := Total + B[24];
            'z': Total := Total + B[25];
            ' ': Total := Total + B[26];
            '1': Total := Total + B[27];
            '2': Total := Total + B[28];
            '3': Total := Total + B[29];
            '4': Total := Total + B[30];
            '5': Total := Total + B[31];
            '6': Total := Total + B[32];
            '7': Total := Total + B[33];
            '8': Total := Total + B[34];
            '9': Total := Total + B[35];
            '10': Total := Total + B[36];
            '0': Total := Total + B[37];
          end;
          NameNum := NameNum + 1;
       until (NameNum = NameLength);
    end;
    cases make things look alot more professional.
    PHP Code:
    Your number is156

    Made by smithsps

    Successfully executed 
    man i got a really low number

    Ps. is this your first script?
    Kindof Inactive...

  6. #6
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yea I do, use case LetterChar of lol, instead of all those if thens!

    Edit : damn it he beat me!

  7. #7
    Join Date
    Dec 2007
    Location
    Michigan, USA
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by FrÕzÑ_§ÕµL View Post
    Yea I do, use case LetterChar of lol, instead of all those if thens!

    Edit : damn it he beat me!
    =P sorry m8 (Whats yo numb?)
    Kindof Inactive...

  8. #8
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @mikevskater
    Thx I will update my script, and this is not my first script. My first script here was:
    prime checker. It should be a few rows down.

    @FrÕzÑ_§ÕµL
    What were you planing on doing?


    Edit: Updated thx to mikevskater

  9. #9
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    program NametoNumber;
    //Made by Smithsps

    var
    Name, LetterChar, TotalStr, NameLengthStr, exit1 : string;
    NameLength, Total, NameNum, NameNum1 : integer;
    A : array of string;
    B : array of integer;

    procedure Report;
    begin
       TotalStr := inttostr(Total);
       NameLengthStr := inttostr(NameLength);
       writeln('Your number is: ' + TotalStr);
       writeln('');
       writeln('Made by smithsps');
       writeln('');
    end;

    procedure Calculation;
    var
      I: Integer;
      S: String;
    begin
       S:= 'abcdefghijklmnopqrstuvqxyz 1234567890';
       LetterChar := copy(Name, NameNum, NameNum1);
       for I:= 1 to NameLength do
         if(pos(Lowercase(LetterChar), S) > 0)then
           Total:= Total + B[pos(Lowercase(LetterChar), S) - 1];
    end;

    procedure Entry;
    begin
       ClearDebug;
       Name := readln('What is your name?');
       Name := trim(name);
       Name := uppercase(name);
       NameLength := Length(Name);
       NameNum := 0
       NameNum1 := 1
       Total := 0;
    end;

    procedure DeclareArray;
    begin
       A:= ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
            'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
       B:= [13, 14, 70, 55, 41, 98, 73, 59, 20, 5, 47, 59, 52, 76, 37, 2, 83, 33, 95, 56, 12,
            74, 82, 87, 64, 69, 0, 48, 35, 57, 22, 67, 40, 96, 54, 15, 67];
         
    end;


    begin
       DeclareArray;
       repeat
          Entry;
          Calculation;
          Report;
          exit1 := readln('Would you like to quit? Y/N');
       until(exit1 = 'y') or (exit1 = 'Y');
    end.
    Notice how I declared the arrays and made the calculation...

    Good job though

  10. #10
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow i don't really understand it...
    can you explain?

  11. #11
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Alright, I'll start with declaring the arrays. You can just declare them like
    MyArray:= [1, 2, 3];
    instead of
    MyArray[0]:= 1;
    MyArray[1]:= 2;
    MyArray[2]:= 3;

    Then to the calculation procedure... first I just turned your repeat..until loop into a for loop. I then, instead of the case statement, or as you had first, the if..then statements, I simply made a string. Just think of it as an array of characters. It would just do the same thing as what you had, but it would instead get the position of the "array"... I explain things terribly, I'm sorry... Hopefully somebody who can explain better will come.

  12. #12
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I think i kinda get it!

    Edit : Updated

  13. #13
    Join Date
    Dec 2007
    Location
    Williston, ND
    Posts
    3,106
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    darn it!!!!
    i only got 70!!!!
    guess im a total noob at that game
    Proud owner of "Efferator" my totally boted main account!
    "You see, sometimes, science is not a guess" -Xiaobing Zhou (my past physics professor, with heavy Chinese accent)

  14. #14
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    You might want a small function to get the alphabet number of a letter.

    SCAR Code:
    {*******************************************************************************
    Function GetAlphabet(C: Char): Integer;
    By: n3ss3s
    Description: Returns the alphabetic number of a character.
    *******************************************************************************}


    Function GetAlphabet(C: Char): Integer;
    Begin
      Result := iAbs(65 - GetKeyCode(C)) + 1;
    End;

  15. #15
    Join Date
    Dec 2007
    Location
    Michigan, USA
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    You might want a small function to get the alphabet number of a letter.

    SCAR Code:
    {*******************************************************************************
    Function GetAlphabet(C: Char): Integer;
    By: n3ss3s
    Description: Returns the alphabetic number of a character.
    *******************************************************************************}


    Function GetAlphabet(C: Char): Integer;
    Begin
      Result := iAbs(65 - GetKeyCode(C)) + 1;
    End;
    You should explain that to him, caus he wont get that if he doesn't get arrays.... like what the function returns/how.
    Kindof Inactive...

  16. #16
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Your number is: 627

    Yay.

    Btw n3s33s, Ord is way more professional xD. Ord > GetKeyCode.
    Verrekte Koekwous

  17. #17
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mike... i do understand... I'm not a total noob.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Checking if a number is a whole number or not?
    By Sandstorm in forum OSR Help
    Replies: 4
    Last Post: 10-26-2008, 04:40 PM
  2. Your number?
    By ub3r |<1||3r*1337* in forum News and General
    Replies: 4
    Last Post: 08-13-2006, 09:15 PM

Posting Permissions

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