How do I set my text to be evaluated as an integer?  ie. 10 is now 2?

I'm trying to duplicate a game in AppleScript that I made in BasicA back when I was eight years old.
This works pretty well. When I guess 10 though, it says that I need to guess a higher number - the number can't be above 10. I realize that it's doing alphabetical order rather than number order, but can't figure out what to do to fix it.
Help... please. Here is my code:
set PlayerName to text returned of (display dialog "Please type your name in the box and click continue." default answer "" buttons {"Continue"} default button "continue") as text
set PlayerScore to 0
set ComputerScore to 0
repeat
set SecretNumber to (random number from 1 to 10) as text
set TheGuess to text returned of (display dialog ("Computer's Score: " & (ComputerScore as integer) & return & PlayerName & ":" & PlayerScore & return & return & "Guess a number 1-10." & return) default answer "" buttons {"cancel", "continue"} default button "continue")
if TheGuess ≠ SecretNumber then
repeat
set ComputerScore to (ComputerScore + 0.3333)
if TheGuess > SecretNumber then
set TheHint to "Hint: Try guessing lower."
else if TheGuess < SecretNumber then
set TheHint to "Hint: Try guessing higher."
else
set TheHint to "Hint: you must guess a number between 1 and 10."
end if
set TheGuess to text returned of (display dialog "Computer's Score: " & (ComputerScore as integer) & return & PlayerName & ":" & PlayerScore & return & return & "Guess a number 1-10." & return & return & "Nope. Try again." & return & return & TheHint default answer "" buttons {"cancel", "continue"} default button "continue")
if TheGuess = SecretNumber then
exit repeat
end if
end repeat
end if
set PlayerScore to (PlayerScore + 1)
display dialog "Computer's Score: " & (ComputerScore as integer) & return & PlayerName & ":" & PlayerScore & return & return & "Congratulations! Play again?" buttons {"exit", "Play again"} default button "Play again"
end repeat
------------------

Use the following:
set PlayerName to text returned of (display dialog "Please type your name in the box and click continue." default answer "" buttons {"Continue"} default button "continue") as text
set PlayerScore to 0
set ComputerScore to 0
repeat
set SecretNumber to (random number from 1 to 10)
set TheGuess to text returned of (display dialog ("Computer's Score: " & (ComputerScore as integer) & return & PlayerName & ":" & PlayerScore & return & return & "Guess a number 1-10." & return) default answer "" buttons {"cancel", "continue"} default button "continue") as number
if TheGuess ≠ SecretNumber then
repeat
set ComputerScore to (ComputerScore + 0.3333)
if TheGuess > SecretNumber then
set TheHint to "Hint: Try guessing lower."
else if TheGuess < SecretNumber then
set TheHint to "Hint: Try guessing higher."
else
set TheHint to "Hint: you must guess a number between 1 and 10."
end if
set TheGuess to text returned of (display dialog "Computer's Score: " & (ComputerScore as integer) & return & PlayerName & ":" & PlayerScore & return & return & "Guess a number 1-10." & return & return & "Nope. Try again." & return & return & TheHint default answer "" buttons {"cancel", "continue"} default button "continue") as number
if TheGuess = SecretNumber then
exit repeat
end if
end repeat
end if
set PlayerScore to (PlayerScore + 1)
display dialog "Computer's Score: " & (ComputerScore as integer) & return & PlayerName & ":" & PlayerScore & return & return & "Congratulations! Play again?" buttons {"exit", "Play again"} default button "Play again"
if button returned of the result is "exit" then exit repeat
end repeat
(42537)

Similar Messages

  • How do you set the text of a Hyperlink component in code

    I am using Visual Web pack in NB 6.0. How do you set the text of a hyperlink component in code?
    Please see screenshots at
    http://coba.usf.edu/departments/isds/faculty/agrawal/projects/java/
    I have a hyperlink in a grid panel. I am using
    hyperlink1.setText("Hello"); in prerender(),
    but the Hyperlink shows up with the text "Hyperlink", whereas I was expecting "Hello". However,
    hyperlink1.setUrl("http://www.usf.edu"); works as expected.
    I tried nesting a static text in the hyperlink as suggested in the Creator guide (ed 2, Google project). I deleted the "Hyperlink" text in the properties editor but then the page turned out blank.
    Thanks
    Manish

    Hi Manish,
    Great to know you were able to fix your issue. The following blog entry has the list of resources you would like to look at for future.
    http://blogs.sun.com/NetBeansSupport/entry/useful_resources_for_visual_web
    Thanks
    K

  • How can i set predictive text to a foreign language

    I'm new to apple and iPhones. I've got everything setup in English but I frequently want to send text and/or email messages in French. When I do this predictive text jumps in and changes things to what it thinks I want in English. e.g. if I type tous it predicts I want toys and inserts it accordingly. How can I set predictive text to a foreign language.
    (p.s. my wife's iPad works fine as it has a button to press for alternative language but I don't see anything similar for iPhone)

    Add the French keyboard.
    Settings > General > Keyboard > Keyboards > Add > French

  • How can I set the text feild in a form to print out the entire feild?

    Right now it's only printing out what shows in the box, I want the box to expand when printed and show all the text entered in the field, how can I set it to do that?

    I think that the font size has to be set in the form itself, not the FDF.

  • How do you set the Text in an Accordion Interaction?

    When trying to set the text in the Accordion Interaction, it behaves very strange. You can't set it. It starts out at 13 and then changes to either 10 or 30.
    Can anyone give some advise on how to set this?
    Thanks.

    Hello,
    Logged that bug (as well, have a long list). Workaround depends on your hardware: for some scrolling the mouse wheel will allow to change font size (doesn't work for me). On my Lenovo Thinkpad I have to use the trackpad, that has a scrollbar, to change the font size. Very cumbersome, was promised that it would soon be patched, crossing my fingers.
    Lilybiri

  • How do I set my text notification to just a vibration?

    Im not even sure if this is possible, but I just want my text notification to be a vibration instead of a sound. I've tried putting the vibrate option on and text sound to 'None', but it doesn't work.

    Will you phone vibrate with sound though? Do you have Mac or PC? It can be done a couple ways.
    1. If you have GarageBand on Mac> You can make a silent ringtone> Send ringtone to itunes>sync and set as text tone.(vibrates twice on mine).
    2. Try getting a silent ringtone from another source to set as text tone.
    I have seen people ask about this for reg. ringtones to set vibrate to unsaved contacts.
    I can explain further if any of this sounds helpful to you.

  • How do i set CollapsiblePanel text to the contents of a panelGrid?

    hi, I have this line of text in a panelGrid and I would like to have displaying in the text attribute of my collapsiblePanel, but I have no idea how to accomplish this
    panelGrid text
    <f:panelGrid id="text1" border="0" columns="8" cellspacing="2" >
         <f:outputLabel value="Case Number" />
         <f:outputLabel value="123 style="color: #660000;" />
         <f:outputLabel value="Default" style="color: #660000;" />
         <f:image id="lockImage" value="../images/lock.gif"> </f:image>
         <f:outputLabel value="Locked by" />
         <f:outputLabel value="user" style="color: #660000;" />
        </f:panelGrid>{code}
    collapsiblePanel
    {code}<f:collapsiblePanel
         id="case1"
         tooltip="Overview"
         text="Overview "  //NEED TO DISPLAY PANELGRID STUFF HERE
         headerPositionCollapsed="horizontal"
         panelHeaderCollapsedStyleClass="panelHeaderCollapsed"
         panelHeaderExpandedStyleClass="panelHeaderExpanded"
         panelStyleClass="panel">
         <iframe name="Overview" height="225" frameborder="0" scrolling="no" style="width: 900px;" src="./caseOverview.jsf" align="middle"/>
    </f:collapsiblePanel>{code}
    Edited by: icecreamman117 on Jul 29, 2008 9:48 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    What is it, the f: taglib which you're using? That doesn't seem to be part of the standard Sun JSF implementation. There is also no such tag with a name like "collapsiblePanel" in the standard Sun JSF implementation.
    It might help to consult the documentation of the JSF implementation or component library which you're using and look around at their homepage if they doesn't have a forum or mailinglist where you can post related questions in.

  • HT3384 How do you set the text layout in Pages on the vertical? How do you center the text?

    How do you align the text vertcially?

    Stru,
    You posted your question in the Pages (word processor) discussion area. Hope you can find your way back to Excel without any difficulty. The answer wouldn't have been much different had you posted in the Numbers discussion.
    Jerry

  • I downloaded the new 4.0..I don't like how everything is set up now. How do I get it back how it was set up on the page? Plus my cache doesn't work now.

    I would like to know how to get it back how it was set up for bookmarks, history etc. I don't like how it is set up now.

    If your library was working on your computer and then popped up empty all of a sudden then this might be what you need...
    Empty/corrupt library after upgrade/crash
    Hopefully it's not been too long since you last upgraded iTunes, in fact if you get an empty/incomplete library immediately after upgrading then with the following steps you shouldn't lose a thing or need to do any further housekeeping. In the Previous iTunes Libraries folder should be a number of dated iTunes Library files. Take the most recent of these and copy it into the iTunes folder. Rename iTunes Library.itl as iTunes Library (Corrupt).itl and then rename the restored file as iTunes Library.itl. Start iTunes. Should all be good, bar any recent additions to or deletions from your library.
    See iTunes Folder Watch for a tool to catch up with any changes since the backup file was created.
    When you get it all working make a backup!
    tt2

  • How do I set the text orientation in a Microsoft Word table cell from LabVIEW?

    In a table in Word (Office 2010) it's possible to change the text orientation in a cell (if you right click on a cell, it's the 'Text Direction...' option). 
    Has anyone figured out how to do this from LabVIEW?  I took a quick look at doing it via ActiveX, but haven't find the correct property/method.  Next step is to try .net.

    Previous post shows the constant values for Excel (my mistake). The following code will change the text orientation for a whole table in Word.
    Ben64

  • How do I set the Text Fields alignment using LiveCycle 7.1

    I created a Form using LiveCycle Designer 7.1 with a few sample Text Fields. Each text box is about 0.75" in height to accomodate a few lines of text within it - it will be holding a description field so the data could be quite large. When my PDF document gets populated with data from an XML file via a .NET Web Page, the text is shown in the center of the Text Field. However, I need the text to be dispalyed at the Top of the Text Field, not in the center. Does anyone know where the option is to make this happen?

    In the paragraph tab. You may have to open it the first time from the Window menu.
    Chris
    Adobe Enterprise Developer Support

  • How I can set up text justify or Bold for the "whole column" of a Table

    Hi,
    It takes time to set up a cell of a Table (Front Panel)for Fonts, justify, Type ... imagine I have to set 1000 cells? Is there any better way to set up one shot for "all cells" in a column and for the "whole Table"? Any one can help me speed this up? Thanks.

    Hi Greg,
    On a related note I would like to ask you a question.
    I wrote an app. in 6.0.1 that took advantage of the defer panel updates option (that I learned about from you, thank you). I was very pleased with the effects.
    Since then, I have taked the same piece of code and have started to use it in another app that I am developing now in 6.1. I no longer see any performance differences using the defer scheme like I had seen earlier. Are the charts failing to "honor" the deferments in 6.1?
    Before you mentioned the table thing (above), I was just thinking that the charts have been updated such that the deferment does not make things any more efficient.
    So...
    Are the charts just faster now?
    or
    Are the charts not honoring...?
    or
    Is Ben just confused (it would not be the first time)?
    Ben
    PS On a general note: You are legendary here at Data Science Automation. I have learned alot from your posting. Thank you.
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I set this text in a JformattedTextField ?

    Hi,
    I have a JFormattedTextField with this mask "#####-###"
    When I'm typing It works very fine, but when I call the setText( "12345") It doesn't work, it clears the field.
    If I call setText( "12345-123" ) It work very fine.
    when I don't have all the numbers in the setText() it clears the field.
    Is it a bug ?
    Can someone help me ?
    Thanks.
    wmiro.

    hi,
    the problem is that I'm using this mask "#####-###" to enter the Brazil postal code, we have some cities which every street has a postal code like this:
    A st, postal code 03986-150
    B st, postal code 03986-250
    but we have some other smaller cities which doesn't have a different postal code each street, like this:
    A neighborhood, postal code 05089
    B neighborhood, postal code 05090
    the the user will type only five numbers, the system will accept, but when the user needs to see the information he can't because the setText() fail.
    I've been thinking I must complete with zeros or change the mask to "00000-000".
    Is that the best way to solve this problem ?
    thanks
    wmiro.

  • How do I set Google as the default search engine in the URL search field (now have Yahoo)?

    I'd like Firefox to use Google as the default search engine for the URL search field, instead of Yahoo as I currently have. I've tried to find a place to reset this in Preferences but can't find a solution. Would be very grateful for any advice. Imagine it's simple.
    NB: I'm talking of the left search field, not the right search engine one where it's easy enough to define.

    You can reset the prefs general.useragent.override and keyword.URL on the about:config page.<br />
    See http://kb.mozillazine.org/about%3Aconfig
    <blockquote>general.useragent.override<br />
    Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 YFF35 Firefox/3.6.8 FBSMTWB<br />
    <br />
    keyword.URL<br />
    http://www.fastbrowsersearch.com/results/results.aspx?s=NAUS&v=19&tid={E2BE0628-2C04-81B6-D310-88BC17CD51D4}&q=</blockquote>
    See these pages and threads about Fast Browser Search (FBSMTWB in the user agent, Help > About).
    *http://www.fastbrowsersearch.com/FBS_Toolbar/Help/helpUninstalling.aspx
    *http://www.pccybertek.com/2009/05/remove-fast-browser-search
    *[/tiki-view_forum_thread.php?forumId=1&comments_parentId=264720]
    *http://forums.mozillazine.org/viewtopic.php?f=38&t=1430845

  • How can I set the width of a Text element?

    Hello! I have created a custom button with this class:
    import javafx.scene.Node;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.Cursor;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.paint.Color;
    import javafx.scene.paint.LinearGradient;
    import javafx.scene.paint.Stop;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.text.Text;
    import javafx.scene.input.MouseEvent;
    public class Button extends CustomNode {
        public var text: String;
        public var x: Integer = 0;
        public var y: Integer = 0;
        public var width: Integer = 90;
        var height: Integer = 25;
        override public function create(): Node {
            return Group {
                content: [
                    Rectangle {
                        cursor: Cursor.HAND;
                        x: this.x;
                        y: this.y
                        width: this.width;
                        height: this.height;
                        arcWidth: 15;
                        arcHeight: 15;
                        effect: DropShadow {radius: 6};
                        fill: LinearGradient {
                            startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                            stops: [
                                Stop {offset: 0.0, color: Color.WHITE}
                                Stop {offset: 1.0, color: Color.LIGHTGRAY}
                        onMouseEntered: function(e: MouseEvent): Void {
                            (e.node as Rectangle).fill = LinearGradient {
                                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                                stops: [
                                    Stop {offset: 0.2, color: Color.WHITE}
                                    Stop {offset: 1.0, color: Color.LIGHTGRAY}
                        onMouseExited: function(e: MouseEvent): Void {
                            (e.node as Rectangle).fill = LinearGradient {
                                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                                stops: [
                                    Stop {offset: 0.0, color: Color.WHITE}
                                    Stop {offset: 1.0, color: Color.LIGHTGRAY}
                        onMousePressed: function(e: MouseEvent): Void {
                            (e.node as Rectangle).fill = LinearGradient {
                                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                                stops: [
                                    Stop {offset: 0.0, color: Color.LIGHTGRAY}
                                    Stop {offset: 1.0, color: Color.WHITE}
                        onMouseReleased: function(e: MouseEvent): Void {
                            (e.node as Rectangle).fill = LinearGradient {
                                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                                stops: [
                                    Stop {offset: 0.0, color: Color.WHITE}
                                    Stop {offset: 1.0, color: Color.LIGHTGRAY}
                    Text {
                        x: this.x + 5, y: this.y + 16
                        content: this.text
    }But, how can I set the Text element centered into the button?

    Stack {
                        layoutInfo: LayoutInfo {
                            width: bind width;
                            height: bind height;
                        content: [Rectangle {
                                width: bind width, height: bind height
                                //fill: bind color;
                                fill: Color.GREEN
                                arcHeight: 20; arcWidth: 20;
                            Text {
                                font: Font {
                                    size: 24
                                textAlignment: TextAlignment.CENTER;
                                wrappingWidth: width;
                                boundsType: TextBoundsType.VISUAL;
                                fill: Color.WHITE;
                                content: bind text;
                    }wrappingWidth: Sets the maximun width of the text
    boundsType: If you put the wrappingWidth var and you want to center a text you MUST set this var to VISUAL

Maybe you are looking for

  • "New or Refurbished" iPod won't sync; error messages

    I recently used my warranty on my old 30 gig classic iPod to get a "new or refurbished" iPod because the battery life was terrible. When i got the iPod everything looked like it was working right, until i got to about 1550/6000 songs. I got a message

  • Video quality from ipod touch over wifi

    It is to my understanding that you can watch video (downloaded from itunes and home video made with ipod touch) through apple tv 2. How is the quality of it, 720p HD or does it get distorted going from little to big screen? Does that include music vi

  • Fault handling in DIServer Interact

    Good Day Mentors, I'm currently testing out how the DIServer works. Now, I am testing Fault handling with the DI Server, and would want to know if there is a way to get multiple Errors from an DI Server Interact call. My test scenario was adding 2 Sa

  • Sending Output to MS word

    Hello all I am planning to write a program that send the out put displayed on webdynpro view to a MS word document.So I request you if you have any plans to solve my problems or any helpfull URLs. Thank you for your time in advance Regards Maruti

  • How to filter the data in dropdown?

    Hello, How to filter the data I got all the project name in dropdown when you select the project name in other textbox the project id will come automatically. so I want to get only those project name that is assigned to that particular user. I have P