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

Username:   Password: 
 RegisterRegister   
 For loop help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
crimson_188




PostPosted: Sun Jan 15, 2006 5:56 pm   Post subject: For loop help

i need help with a anti-tank drawing to loop 10 times across the screen?

here is the code i got so far:

var line1,line2 : char
line1:=Draw.ThickLine (10,90,30,110,5,25)
line2:=Draw.ThickLine (30,90,10,110,5,25)
for i : 1..10
put Line1,line2
end for

any help is appriciated

Thanks
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Jan 15, 2006 5:59 pm   Post subject: (No subject)

That's not how you draw at all! Draw.ThickLine is a procedure, and hence does not return a value: you cannot assign Draw.ThickLine to a variable (easily).

Try this:
code:

for i : 1 .. 10
    Draw.ThickLine (10, 90, 30, 110, 5, 25)
    Draw.ThickLine (30, 90, 10, 110, 5, 25)
end for

Now, alter the coordinates so that they depend on the for loop counter, i.
crimson_188




PostPosted: Sun Jan 15, 2006 6:04 pm   Post subject: (No subject)

Thanks Alot!
crimson_188




PostPosted: Sun Jan 15, 2006 6:12 pm   Post subject: (No subject)

so how would you write the variables Draw.ThickLine (10, 90, 30, 110, 5, 25)
, and Draw.ThickLine (30, 90, 10, 110, 5, 25) into an object?

var anti : int?
anti:=???

Thanks

P.S. And yes i am new to Turing[/quote]
Delos




PostPosted: Sun Jan 15, 2006 8:14 pm   Post subject: (No subject)

crimson_188 wrote:
so how would you write the variables Draw.ThickLine (10, 90, 30, 110, 5, 25)
, and Draw.ThickLine (30, 90, 10, 110, 5, 25) into an object?

var anti : int?
anti:=???

Thanks

P.S. And yes i am new to Turing


Woah there buddy. Let's not get ahead of ourselves. Baby steps.
Variables are little pieces of memory (RAM to be precise) that your computer allocates, and in which bits of information will be stored. Sometimes bytes. (Sorry, bad joke).
In programming, we have various routines that we frequently employ and hence we give them special names because they are just so peachy. For instance, a function is a series of commands that take a particular value, and return a different value. So, if you gave a function the number 2, it might return the number 8 (if it cubed the number, for instance).
A procedure is a series of commands that can take arguments (paramteres) and do stuff with them. So, if you gave a procedure the number 2, it might take it, cube it, then draw a large 8 on the screen to show you so.
Subtle difference? Perhaps, but once you get into it a bit more you'll understand why they are so very, very different.

Now. Draw.ThinkLine() is a procedure, not a function, and not a variable. Hence, you provide it with a number of parameters and it does something for you. You don't need to create a seperate variable to be able to use it in the way you were experimenting with.

It is worthwhile to add, while we're at it, that your line of thinking is not entirely flawed. There is a rather large area of programming today known as Object Oriented Programming. You may have heard of it - people say it's the next sliced bread...Anyhow, in OOP, very often you can't do things like draw lines unless you have a special variable (an object) in the first place to do stuff with. Wonderful, complicated, intuitive stuff - but not just yet.

Oh. Use [code] tags or face my wrath. However mint-scented it may be, it's still wrath.
Cervantes




PostPosted: Sun Jan 15, 2006 9:00 pm   Post subject: (No subject)

Perhaps you're looking to replicate that exact procedure call (with those exact parameters) easily? You could make another procedure that calls your Draw.ThickLine (10, 90, 30, 110, 5, 25) , like this:
code:

proc draw_my_thick_line
     Draw.ThickLine (10, 90, 30, 110, 5, 25)
end draw_my_thick_line


Delos wrote:
Oh. Use [code] tags or face my wrath. However mint-scented it may be, it's still wrath.

ROFL
GoVikingsGo




PostPosted: Mon Jan 16, 2006 4:12 pm   Post subject: (No subject)

i think he wants to be able to call the method drawThick line numerous times so he sets it to a variable. I think if I can understand the logic.


But yeah what Delos said is right
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  [ 7 Posts ]
Jump to:   


Style:  
Search: