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

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




PostPosted: Mon Nov 10, 2008 11:50 am   Post subject: replace function

just wondering

i found a script that draws a picture of a skull and crossbones by drawing dots
the script is huge like 30 seconds of fast scrolling huge

and iu thought it wouyld be cool if i put in a delay after one so it draws one dot at a time and you watch it fill in

BUT i don't want to send pressing downarrow and then enter to make spaces here is a sample of the code


raw.Dot (0, 0, 7)
Draw.Dot (0, 1, 7)
Draw.Dot (0, 2, 7)
Draw.Dot (0, 3, 7)
Draw.Dot (0, 4, 7)
Draw.Dot (0, 5, 7)
Draw.Dot (0, 6, 7)
Draw.Dot (0, 7, 7)
Draw.Dot (0, 8, 7)
Draw.Dot (0, 9, 7)
Draw.Dot (0, 10, 7)
Draw.Dot (0, 11, 7)
Draw.Dot (0, 12, 7)



i think you ge the idea

and so instead of pressing keys on the keyboard for hours i was wonderting if the replace function cn do something like thii

FIND WHATl: Draw.Dot ([make this anything])
REPLACE WITH: Draw.Dot ([make this anything]) delay (50)




ya so if this is possible please tell me Mr. Green
Sponsor
Sponsor
Sponsor
sponsor
Vermette




PostPosted: Mon Nov 10, 2008 12:12 pm   Post subject: RE:replace function

Notepad -> Edit -> Replace

replace ")" with ") delay(50)" if that's the proper syntax for what you're trying to do. I'm going on a limb here and thinking you don't have other code mixed in, so you should be able to run that and be done in a few seconds.

Now, I'm a little busy right now at work, but I'm sure before I get home to give you a little more info someone will come along and post some info on using regex to get the job done. This would be a single line problem/solution on a *nix system Wink
Insectoid




PostPosted: Mon Nov 10, 2008 12:20 pm   Post subject: RE:replace function

Turing has a replace function built in.
delparnel




PostPosted: Mon Nov 10, 2008 12:27 pm   Post subject: Re: replace function

Self-modifying code??
Insectoid




PostPosted: Mon Nov 10, 2008 12:29 pm   Post subject: RE:replace function

no...it's a button, you click it, type what you want to replace, and what to replace with, and click replace...

So, he wants to replace the code while it's running?
OneOffDriveByPoster




PostPosted: Mon Nov 10, 2008 12:43 pm   Post subject: Re: replace function

ecookman @ Mon Nov 10, 2008 11:50 am wrote:
and iu thought it wouyld be cool if i put in a delay after one so it draws one dot at a time and you watch it fill in
Might be more fun to draw one of the dots at random (and not in order).
The_Bean




PostPosted: Mon Nov 10, 2008 4:10 pm   Post subject: Re: replace function

Well I was bored during fourth today and saw this, so i decided to make something using Draw.Dot myself.
It turned out to be 62724 lines with delays.
Takes roughly 22 minutes of mouse scrolling to get to the bottom. (Yes I scrolled the mouse for 22 minutes straight)
Arranged from darkest to lightest colours by row.
Only took an hour to make minus the scrolling. (thats 8.7 pixels/second, I know I'm crazy)
Doesn't draw any white dots.
Totally worth it.
Currently working on something 4 times the size.



DrawDot.t
 Description:
Muahahahaha

Download
 Filename:  DrawDot.t
 Filesize:  1.23 MB
 Downloaded:  106 Time(s)

Dan




PostPosted: Mon Nov 10, 2008 5:12 pm   Post subject: RE:replace function

You could just make a function that takes the same arguments as Draw.dot and then has two comands in it, the first is Draw.Dot(the args from the function) and then the second is a delay.

Then you would only have to replace the Draw.Dot with the function name of the function you made. This method also makes it easier to change the length of the delay.


If turing had better OOP you would be able to make a child of Draw and override Draw.dot with your own function with a delay and then call the super.dot. However i don't think turing lets you make a child class of Draw (tho i have not tryed).
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Sponsor
Sponsor
Sponsor
sponsor
andrew.




PostPosted: Mon Nov 10, 2008 7:14 pm   Post subject: RE:replace function

This is not related to the original post, but Dan said something about OOP and that triggered a question in my head. I remember a while ago, I got my hands on a version of Turing that was object-oriented. I don't have it anymore, but I was just wondering if anyone has ever used this and how good is the OOP in it?
[Gandalf]




PostPosted: Mon Nov 10, 2008 7:27 pm   Post subject: RE:replace function

Any of the (relatively) newer versions of Turing support OOP, though not extremely well. The download section has various object oriented versions (usually just your standard version) of Turing available to download.

For more info about this, take a look at Cervantes' trilogy of tutorials on classes.
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  [ 10 Posts ]
Jump to:   


Style:  
Search: