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

Username:   Password: 
 RegisterRegister   
 GUI Troubleshooting
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Vicous




PostPosted: Sat May 15, 2004 2:02 pm   Post subject: GUI Troubleshooting

Hmm. Well, I'm programming a calc for SimRTK if anyones ever heard of it, and I ran into a very weird error. I run the code and when I type anything in the text fields I created at the top, it brings up an error. Try it for yourself:

Breaker.FCpages.com/SimCalc.t



SimCalc.t
 Description:

Download
 Filename:  SimCalc.t
 Filesize:  15.51 KB
 Downloaded:  120 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
guruguru




PostPosted: Sat May 15, 2004 3:25 pm   Post subject: (No subject)

Move your initialization of the text box after the initialization of your text fields. But more problems occur.

And wow, your programming is VERY unefficitent. For one thing, DO NOT declare all you check boxes individually. Make them an array... for example in the initialization- instead of doing what you did, try this:

code:

var checkbox : array 1 .. 62 of int
var checkboxNames : array 1 .. 62 of string  := init("Aid", "Ambush", etc...)

for x : 0 .. 3
    for i : 1 .. 17
        exit when i + x * 17 > 62
        checkbox(i + 17 * x) := GUI.CreateCheckBox (20 + 100 * x, maxy - 175 + 25 * i, checkboxNames(i + 17 * x), BoxEntered)
    end for
end for


And voila! 124 lines into 8!!! And change everything else like youre enable and disable procs and youre program will go from 450 lines to <100!!![/b]
Delos




PostPosted: Sat May 15, 2004 3:32 pm   Post subject: (No subject)

Here's a few tips:

code:

procedure TextEntered (text : string)
    % Name := GUI.GetText (NameTxt)
    % Age := GUI.GetText (AgeTxt)
    % Class := GUI.GetText (ClassTxt)
    % Lead := strint (GUI.GetText (LeadTxt))
    % War := strint (GUI.GetText (WarTxt))
    % Int := strint (GUI.GetText (IntTxt))
    % Pol := strint (GUI.GetText (PolTxt))
    % Cha := strint (GUI.GetText (ChaTxt))
    GUI.SetSelection (NameTxt, 0, 0)
    GUI.SetActive (NameTxt)
end TextEntered


Don't do the whole GUI.GetText thing here...that's not what this procedure if for. In fact, you really couldnt' get the text from any of those other streams as they don't have a procedure associated with them. I.e., you HAVE to make a seperate procedure for each and every text field you make...or...you could do a bit of cheating and have one procedure that can distinguish between streams...but that's getting ahead of yourself.

Text, declare your text fields BEFORE your text boxes. Don't ask me why...I have a feeling that it has something to do w/ the input/output logistics of text fields vs. boxes...for now, just think of it this way: "it works".

Another tip.
There is no need to be sooo specific w/ your variables...it would be a lot easier for you to have a single array, possible "var textFields : array 1..## of int" that you would use for your streams. You could always comment on the seperate elements' functions. This way you save typing space, and line space.


Hey! guruguru got in before me! Meh! But hey, he said the same things I did...good good...hehehe
Vicous




PostPosted: Sat May 15, 2004 4:12 pm   Post subject: (No subject)

Bad news is I'm rewriting my entire program
Good news is with a little text editing and with the above code, it's taken me all of ten minutes to rewrite all the code for the checkboxes Razz

So Text Fields before text boxes huh? I can see why that might cause it (in that guessing way of mine Rolling Eyes )

Thanks!
Vicous




PostPosted: Sat May 15, 2004 4:29 pm   Post subject: (No subject)

Delos wrote:
Don't do the whole GUI.GetText thing here...that's not what this procedure if for. In fact, you really couldnt' get the text from any of those other streams as they don't have a procedure associated with them. I.e., you HAVE to make a seperate procedure for each and every text field you make...


So I can't make blanket procedures such as the one used to get the results of all the checkboxes? Or does that only apply to text?
Vicous




PostPosted: Sat May 15, 2004 9:23 pm   Post subject: (No subject)

OK, next problem. I Just found out I can't copy text from a Text box.

I need a box to put text where the user can copy the text and paste it somewhere. I need to be able to do this for multiple lines of text, so a text Field won't due. Is there a command to allow text in a text box to be copied? Someway of pasting text directly to the clipboard? Anything?
jonos




PostPosted: Sat May 15, 2004 10:18 pm   Post subject: (No subject)

Make a new Turing window and do:

code:

setscreen("text");

I think that is right, just make sure it is as "text" not graphics.

If it is set as text then you can copy from it, but as to pasting I'm pretty sure that is not possible in Turing unless you make one yourself.
Vicous




PostPosted: Sun May 16, 2004 6:05 am   Post subject: (No subject)

Wow, I woke up with the same idea! Just wasn't sure if it was possable or not, had to go looking for the code!

Thanks!
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: