Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Disable Turing Autoscroll
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Timothy Willard




PostPosted: Fri Jun 28, 2013 6:35 pm   Post subject: Disable Turing Autoscroll

What is it you are trying to achieve?
I am trying to do a "custom get" so I can eliminate capitals from being entered, as well as detect when someone presses the up arrow (so that I can load their last entered input). However, my customGet is causing issues.


What is the problem you are having?
My customGet works by getting each character they enter, and then adding it to "tempText", then displaying temptext on (maxrow, 1). However, everything I put tempText, it immediately scrolls, and whatever I put is then one row too high.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
This is my customGet code. I call it with: Input := customGet()

Also, I do realize there are some bugs current in this code (for example, immediately hitting backspace will cause the computer to try and make temptext := temptext (1..0)). Currently I am just worried about the autoscrolling, because if I can't fix this then I can't use the function anyway.

Turing:
fcn customGet () : string
    tempText := ""
    var inputKey : string (1)
    var numArrowKey : int := numInputs + 1

    loop
        getch (inputKey)
        if ord (inputKey) >= 65 and ord (inputKey) <= 90 then
            inputKey := chr (ord (inputKey) + 32)
            tempText := tempText + inputKey
        elsif (ord (inputKey) >= 97 and ord (inputKey) <= 122) or ord (inputKey) = 32 or (ord (inputKey) >= 48
                and ord (inputKey) <= 57) then
            tempText := tempText + inputKey
        elsif ord (inputKey) = 10 then
            exit
        elsif ord (inputKey) = 200 then
            numArrowKey -= 1
            if numArrowKey <= 0 then
                numArrowKey := 1
            end if
            tempText := previousInputs (numArrowKey)
        elsif ord (inputKey) = 208 then
            numArrowKey += 1
            if numArrowKey > numInputs then
                numArrowKey := numInputs
            end if
            tempText := previousInputs (numArrowKey)
        elsif ord (inputKey) = 8 then
            tempText := tempText (1 .. length (tempText) - 1)
        end if
        locate (maxrow, 1)
        put tempText
        View.Update
    end loop
    result tempText
end customGet


Please specify what version of Turing you are using
4.1
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri Jun 28, 2013 6:59 pm   Post subject: RE:Disable Turing Autoscroll

When you put tempText, add a .. to prevent Turing from adding a newline.

After fixing this, you'll notice:

1. Pressing backspace will move the cursor backwards but won't appear to erase the text, because you don't clear the screen (or even just that row).

2. Holding down backspace will crash your program.

I'll leave fixing those up to you.
Timothy Willard




PostPosted: Fri Jun 28, 2013 7:02 pm   Post subject: Re: Disable Turing Autoscroll

Thanks.

Also, I feel a complete idiot for not remembering ..

Anyway, yeah, I know about those errors, and there are a couple that aren't apparent because they involve variables defined elsewhere, but they shouldn't be too hard to fix.
Thanks again.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: