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

Username:   Password: 
 RegisterRegister   
 New Commands for Turing
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cervantes




PostPosted: Wed Jun 22, 2005 8:36 pm   Post subject: (No subject)

Token wrote:
i think for now we should just keep them in separate modules and then start incorperating it into their respective sections afterwards


[accent="butchered french"]En contrare, mon amie (sp?).[/accent]
That's more work. There's no harm in making modifications all the way through. As I suggested in my email to stargate, everyone working on the project should have multiple copies of the turing install on their harddrive. (3 copies, I think.) 1.) is the main one. 2.) is for their own modifications. 3.) is for testing the modifications of others. If you want to test someone elses modifications, just copy his new .tu files into the predefs folder of the third install and try them out.

Oh, also I forgot to add in my last post: Jorbalax, why have just an ArrayShuffle module? Why not make a general Array module that has shuffling, sorting, & searching?

On that note, I was wondering earlier about having modules inside modules. It can be done, though Turing will give you warnings all over the place. Despite this, everything runs fine. I think StarGate, you should ask Holtsoft about looking into this. Having modules within modules would help to keep things better structured (for example, Array module contains a shuffle module, sort module, and search module). Warnings appearing all over the place whenever someone trys to use the new features would surely not be so impressive.

Zylum: Sounds awesome!! Very Happy
Sponsor
Sponsor
Sponsor
sponsor
36002




PostPosted: Thu Jun 23, 2005 7:52 am   Post subject: (No subject)

What about the net commands? Can we do anything about those? Like somehow speed it up, compression maybe? Also, in PHP there is a command called "explode" which breaks up a string into an array at a certain symbal. An example syntax maybe for turing could be:
code:

string := "hi::how::are::you"
new_array := Explode (string, new_array, "::")
/*
i'm a bit rusty with turing and php, but new_array should include:
new_array[0] := "hi"
new_array[1] := "how"
new_array[2] := "are"
new_array[3] := "you"
*/
MysticVegeta




PostPosted: Thu Jun 23, 2005 10:47 am   Post subject: (No subject)

Hi, I made something similar to what you were saying, the command is ->
stringSplit (sentence, letter)

code:
/*
 By: Tan (aka Mystic)

 For: "NEW COMMANDS FOR TURING"

 This program takes a string and splits it depending on what the splitting letter is
 You may enter any letter but if the letter is not present in the sentence, the entire sentence is the
 result. Comments are put to guide how it works.

 Usage: Many Encryption problem deal with removing spaces, and many other problems deal with removing certain characters,
 not a really necessary program but still useful sometimes.

 */

fcn stringSplit (line : string, letter : string) : string  %Creating a function that outputs the result and takes a word, and letter
    var splitter : string  % The main Answer

    for x : 1 .. length (line)               % This loop checks whether the beginning is from a space or not or the series of
        if line (x) not= letter then         % letters in the beginning
            splitter := line (x .. *)        % If it finds the non-splitter inside
            exit
        end if
    end for

    for decreasing x : length (splitter) .. 1   %Same as above loop. except this time it checks whether In the end
        if splitter (x) not= letter then        %If there are letters left
            splitter := splitter (1 .. x)
            exit
        end if
    end for

    loop %Looping untill the sentence is letter free!
        exit when index (splitter, letter) = 0  %Exits the loop, when no letters are left in the sentence
        splitter := splitter (1 .. index (splitter, letter) - 1) + splitter (index (splitter, letter) + 1 .. *) %Main splitting
    end loop %Self Explainatory (maybe =P)

    result splitter  %Resulting the answer
end stringSplit

put stringSplit ("      I    THINNNNNK IT WORKS ? ? ? ?  ASND A DAS DSDA DD A ", " ") % Well the sentences, splitting letter here.
zylum




PostPosted: Thu Jun 23, 2005 1:50 pm   Post subject: (No subject)

yeah before the down time i suggested we incorperate regular expressions. its really powerful for handling strings. you guys should check it out in other languages such as java and perl
MysticVegeta




PostPosted: Thu Jun 23, 2005 1:57 pm   Post subject: (No subject)

true, my previous post's idea was based on
code:
string.split();

code from Java.
Jorbalax




PostPosted: Thu Jun 23, 2005 2:31 pm   Post subject: (No subject)

Here's one I made today. It's a button-switch for characters using Input.Keydown. Normally, when you're running Input.KeyDown in a loop and you press a button, the if statement you have set for that button will continuously run as it is down.

Example Code
code:

import Key

var input : array char of boolean

loop
Input.KeyDown (input)
if input (KEY_RIGHT_ARROW) then
Draw.FillOval (maxx div 2 - 20, maxy div 2, 20, 20, Rand.Int (1, 10))
end if

if Key.Check (input, KEY_LEFT_ARROW) then
Draw.FillOval (maxx div 2 + 20, maxy div 2, 20, 20, Rand.Int (1, 10))
end if

Key.Switch (input, KEY_LEFT_ARROW)
end loop


Thanks for the ideas, Cervantes, I'll try them.



Key.tu
 Description:
Add on for Key.InputDown that allows you to make character switches easily.

Download
 Filename:  Key.tu
 Filesize:  673 Bytes
 Downloaded:  76 Time(s)

Cervantes




PostPosted: Thu Jun 23, 2005 4:14 pm   Post subject: (No subject)

36002 wrote:
What about the net commands? Can we do anything about those? Like somehow speed it up, compression maybe? Also, in PHP there is a command called "explode" which breaks up a string into an array at a certain symbal. An example syntax maybe for turing could be:
code:

string := "hi::how::are::you"
new_array := Explode (string, new_array, "::")
/*
i'm a bit rusty with turing and php, but new_array should include:
new_array[0] := "hi"
new_array[1] := "how"
new_array[2] := "are"
new_array[3] := "you"
*/

I do not believe it is possible for a function in Turing to result an array with a dynamic upper bounds. Sad
StarGateSG-1




PostPosted: Thu Jun 23, 2005 5:36 pm   Post subject: (No subject)

I looks like there are alot of nice things coming together, this is much better than I expected, I have decided that the first thing I will do is work of the GUI.SaveFile and OpenFile, but I think I might get a summer job so I will have to squeeze it in, as for the list I will add that to the forst post Token.

There will always be somethings we can't edit so we can just accpet those how they are and cervates is right we don't have to jump right on and make all these new ones we can take existing commands and edit and add to them.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Fri Jun 24, 2005 5:20 pm   Post subject: (No subject)

Yeah, but you see, it would be hard to change some of the existing commands because they were written in other languages...

Alright, here's my meek contribution, I added to the Draw module. Just copy the attached file to your "Turing/Support/predefs" folder and overwrite. I assure everyone that it does not mess anything up, you can always just edit it out if you want. Back up the original if you want, but its really not neccessary Rolling Eyes.

Here's the syntax:
code:
Draw.ThickOval (x, y, xRadius, yRadius, thickness, Color : int)
Draw.ThickBox (x1, y1, x2, y2, thickness, Color : int)


Oh, the Draw.ThickOval doesn't look perfectly because of the way ovals are made in Turing. I will try to fix this later, right now I just made everything as simple as possible Wink.

Right, right, and here's the attachment:

*EDIT* Alright, updated.



Draw.tu
 Description:
Draw Module Further Updated

Download
 Filename:  Draw.tu
 Filesize:  4.29 KB
 Downloaded:  108 Time(s)

Cervantes




PostPosted: Fri Jun 24, 2005 5:42 pm   Post subject: (No subject)

Gandalf, let's reduce the number of boxes that need to be drawn from a possibly large number (number of boxes to be drawn equals the value of thickness) to a cap of four, regardless.

code:

    proc ThickBox (x1, y1, x2, y2, thickness, Color : int)
        Draw.FillBox (x1, y1, x1 + thickness, y2, Color)    %left side
        Draw.FillBox (x2 - thickness, y1, x2, y2, Color)    %right side
        Draw.FillBox (x1, y1, x2, y1 + thickness, Color)    %bottom
        Draw.FillBox (x1, y2 - thickness, x2, y2, Color)    %top
    end ThickBox

And as an added bonus of doing it this way, you can create a checkerboard effect by using a negative thickness.
lyam_kaskade




PostPosted: Fri Jun 24, 2005 7:11 pm   Post subject: (No subject)

Couldn't you just draw two boxes?
code:

proc ThickBox (x1, y1, x2, y2, thickness, Color : int)
    Draw.Box (x1, y1, x2, y2, Color)
    Draw.Box (x1 + thickness, y1 + thickness, x2 - thickness, y2 - thickness, Color)
    Draw.Fill (x1 + 1, y1 + 1, Color, Color)
end ThickBox
Token




PostPosted: Fri Jun 24, 2005 7:38 pm   Post subject: (No subject)

you could but if ur using this over another picture and there was a line diagonally through it, only one side of the line would be filled
Cervantes




PostPosted: Fri Jun 24, 2005 8:03 pm   Post subject: (No subject)

There's also the question of speed.
code:

proc ThickBox (x1, y1, x2, y2, thickness, Color : int)
    Draw.FillBox (x1, y1, x1 + thickness, y2, Color)        %left side
    Draw.FillBox (x2 - thickness, y1, x2, y2, Color)        %right side
    Draw.FillBox (x1, y1, x2, y1 + thickness, Color)        %bottom
    Draw.FillBox (x1, y2 - thickness, x2, y2, Color)        %top
end ThickBox

proc ThickBox2 (x1, y1, x2, y2, thickness, Color : int)
    Draw.Box (x1, y1, x2, y2, Color)
    Draw.Box (x1 + thickness, y1 + thickness, x2 - thickness, y2 - thickness, Color)
    Draw.Fill (x1 + 1, y1 + 1, Color, Color)
end ThickBox2


var currentTime := Time.Elapsed
for i : 1 .. 200
    ThickBox (50, 50, 100, 100, 20, black)
end for
put Time.Elapsed - currentTime

currentTime := Time.Elapsed
for i : 1 .. 200
    ThickBox2 (50, 50, 100, 100, 20, black)
end for
put Time.Elapsed - currentTime

I dislike using Draw.Fill.
jamonathin




PostPosted: Fri Jun 24, 2005 8:22 pm   Post subject: (No subject)

Hmm, valid point. The draw fill ran 28.22 times slower on my comp. I was trying to put together something for the drawthickoval thinger so that it wasn't so choppy, but I was using Draw.Fill, and it would have run into too many problems anyways.
[Gandalf]




PostPosted: Fri Jun 24, 2005 8:53 pm   Post subject: (No subject)

Alright, I've finished my two additions to the Draw module. Draw.ThickBox I stuck with Cervantes' way for obvious reasons. For the Draw.ThickOval, I changed it to Draw.ThickCircle since usually we are making cirlces (ovals can be added later Smile).

ThickCircle runs much slower now, but it also adds a kind of effect Smile. To make the speed a bit faster when it can be I added compensation.

Well, tell me what you think, I'll add some more stuff later.



Draw.tu
 Description:
Draw Module

Download
 Filename:  Draw.tu
 Filesize:  4.6 KB
 Downloaded:  86 Time(s)

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 3 of 8  [ 119 Posts ]
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Jump to:   


Style:  
Search: