Pascal Help

KaineKaine Join Date: 2002-08-07 Member: 1096Members, Constellation
<div class="IPBDescription">this ones got me :/</div> ok, so i got this cool new IRC client, 'cause i'm sick of mIRC. its stylish, its new, its got bling.

it even has pascal as its scripting language.

so i'm trying to make this script to automatically convert any given word, or series of words, into phoenetics (alpha, bravo, charlie etc...). now the fkn thing is giving me an error when i try to use it - <i>"* Script Error in unit 'Bersirc' on line 561 : Type of expression must be integer"</i>

if you know your pascal, please give me a hand here.

<!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
55Procedure Ph(words: string);
552 var
553 i: integer;
554 final, temp: string;
555 begin
556   i := 0;
557   final := '';
558   for i := 1 TO length(words) DO
559   begin
560     temp := words[i];
561     case temp of
562       'a': final := final + 'alpha';
563       'b': final := final + 'bravo';
564       'c': final := final + 'charlie';
565       'd': final := final + 'delta';
566       'e': final := final + 'echo';
567       'f': final := final + 'foxtrot';
568       'g': final := final + 'golf';
569       'h': final := final + 'hotel';
570       'i': final := final + 'india';
571       'j': final := final + 'juliet';
572       'k': final := final + 'kilo';
573       'l': final := final + 'lima';
574       'm': final := final + 'mike';
575       'n': final := final + 'november';
576       'o': final := final + 'oscar';
577       'p': final := final + 'papa';
578       'q': final := final + 'quebec';
579       'r': final := final + 'romeo';
580       's': final := final + 'sierra';
581       't': final := final + 'tango';
582       'u': final := final + 'uniform';
583       'v': final := final + 'victor';
584       'w': final := final + 'whiskey';
585       'x': final := final + 'x-ray';
586       'y': final := final + 'yankee';
587       'z': final := final + 'zulu';
588     otherwise final := final + words[i];
589     end;
590   end;
591     say(final); //[Kaine]: basically acts as mIRC command /say - speaks the text in 'final' into the current channel.
592 end;<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

Comments

  • HempHemp Join Date: 2003-05-13 Member: 16274Members
    Hrm, I may be a little rusty with pascal but I believe case statements can only
    be a character or an integer. Since you are only giving temp one character,
    you can change to temp:char; This should fix the problem. Hopefully ;D

    Hemp
    Sleepless NS 2.01 RC 2
    ns.rh.rit.edu
  • Nil_IQNil_IQ Join Date: 2003-04-15 Member: 15520Members
    GAH!

    This was my last day of college (high-school) until January and I thought I wouldn't have to look at another Pascal program until then. How wrong I was. Why do you haunt me Pascal?
  • CodemanCodeman Join Date: 2002-11-21 Member: 9497Members, Constellation, Reinforced - Shadow
    edited December 2003
    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    var
     temp: char;
    <!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    case only works on integer values (yes, deep down inside a char is really an integer with an ego...)

    Hemp was right.

    EDIT: I suggest you convert temp to lowercase (to avoid it looking stupid when you feed it capitals, as atm it wont convert them). There are better ways to do this (lookup table), but i guess you aren't gonna use it enough to care how fast it is....

    -- Codeman
Sign In or Register to comment.