<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><br><br>--- On <b>Sun, 7/4/10, nicolas cellier <i>&lt;nicolas.cellier.aka.nice@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: nicolas cellier &lt;nicolas.cellier.aka.nice@gmail.com&gt;<br>Subject: [Newbies] Re: Translation from old basic program<br>To: beginners@lists.squeakfoundation.org<br>Date: Sunday, July 4, 2010, 1:40 PM<br><br><div class="plainMail">kirand &lt;kirandev &lt;at&gt; ukr.net&gt; writes:<br><br>&gt; <br>&gt; Hi!<br>&gt; <br>&gt; Is anybody remember basic?<br>&gt; <br>&gt; I am a beginner and cant understand how to make this program in Smalltalk. I <br>&gt; found it in old magazine from 80-th years :)<br>&gt; So, this is the program. It makes interest graphics.<br>&gt; <br>&gt; 10 INPUT "Enter a number"; N<br>&gt; 20 DIM X(N), Y(N)<br>&gt; 30 R =
 120<br>&gt; 40 DT = 2 * 3,1416 /N<br>&gt; 50 T = 0<br>&gt; 60 FOR I = 1 TO N<br>&gt; 70 T = T + DT<br>&gt; 80 X(I) = 160 + R*COS (T): Y(I) = 125 - R*SIN (T)<br>&gt; 90 NEXT I<br>&gt; 95 CLSZ<br>&gt; 100 FOR I = 1 TO N-1<br>&gt; 110 FOR J= I+1 TO N<br>&gt; 120 PLOT X(I), Y(I), 3<br>&gt; 130 LINE X(J), Y(J)<br>&gt; 140 NEXT J<br>&gt; 150 NEXT I<br>&gt; 160 STOP<br>&gt; <br>&gt; Some remarks can help. PLOT+LINE is BitBlt&gt;&gt;drawFrom:to:. DIM X(N), Y(N) is <br>&gt; PointArray instance.<br>&gt; <br>&gt; If anobody make it pls give me a code to see how. <br>&gt; <br><br>First attempt: draw directly on Display<br><br>| n xy r dt brush |<br>n := FillInTheBlank request: 'Enter a number' initialAnswer: ''.<br>n := Number readFrom: n.&nbsp; "Transform the String into a Number" <br>xy := Array new: n.<br>dt := Float twoPi / n.<br>r := 120.<br>1 to: n do: [:i | <br>&nbsp; &nbsp; "Mind the order or operations here, Smalltalk interprets left to right"<br>&nbsp;
 &nbsp; xy at: i put: ((i*dt) cos * r +160) @ ((i*dt) sin negated * r + 125)].<br>brush := Form extent: 3 @ 3.<br>brush fillBlack.<br>1 to: n-1 do: [:i | <br>i+1 to: n do: [:j | <br>&nbsp;&nbsp;&nbsp; Display<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drawLine: brush<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; from: (xy at: i)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; to: (xy at: j)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; clippingBox: Display boundingBox<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rule: Form paint<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fillColor: nil]].<br><br>Second attempt: draw on a Form, copy the Form on Display,<br>restore the Display after 10 seconds.<br><br>| n xy r dt form brush |<br>n := (FillInTheBlank request: 'Enter a number' initialAnswer: '') asNumber.<br>dt := Float twoPi / n.<br>r := 120.<br>xy := (1 to: n) collect: [:i | <br>&nbsp;&nbsp;&nbsp; ((i*dt) cos * r +160) @ ((i*dt) sin negated * r + 125)].<br>form := Form extent:
 300@300.<br>brush := Form extent: 1 @ 1.<br>brush fillBlack.<br>1 to: n-1 do: [:i | <br>i+1 to: n do: [:j | <br>&nbsp;&nbsp;&nbsp; form<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drawLine: brush<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; from: (xy at: i)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; to: (xy at: j)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; clippingBox: form boundingBox<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rule: Form paint<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fillColor: nil]].<br>form displayOn: Display.<br>[(Delay forSeconds: 10) wait. Display restore] fork<br><br>Nicolas<br><br>Hi kirand, Hi Nicolas<br><br>Thought I'd give it a quick try. Here we just make a polygon and allow it to open. Heavily used the underlying goal of the problem to guide what is being done. I had fun seeing how easily I could do this in squeak. I have no idea if it meets the original purpose of the request.<br><br>If I really was feeling lazy I would have invented a
 Number fromUser method to simplify the input. I half expected someone to already have done so.<br><br>Lazy mans method:<br><br>n := (FillInTheBlank request: 'Enter a number' initialAnswer: '') asNumber.<br>(plottingPoints :=<br>(0 to: 360 by:&nbsp; 360 /n) collect: [ :each | (Point r: 120 degrees: each) + (160@125)&nbsp; ] ) .<br><br>(LineMorph initializedInstance setVertices: plottingPoints )<br>openInWorld .<br><br><br>Yours in curiosity and service, --Jerome Peace<br><br><br>_______________________________________________<br>Beginners mailing list<br><a ymailto="mailto:Beginners@lists.squeakfoundation.org" href="/mc/compose?to=Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br><a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br></div></blockquote></td></tr></table><br>