Loop and lines question
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-18 09:34 AM
2014-12-18
09:34 AM
Sorry for my newbie question but I can't find solution for my case:
I need to draw a line beetween two points given by a loop:
For k=0 TO 2 STEP 1 x= 5 * k y= 10 * k NEXT kSo the effect would be two sets of values for X and Y :
x1 = 5
y1= 10
x2= 10
y2= 20
And I want a line beetween x1, y2, x2, y2
line2 5,10,10,20 !!!! or ... line2 x,y,x,yHow am I supposed to get those x1, y1, x2 and y2 ?
8 REPLIES 8

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-18 09:49 AM
2014-12-18
09:49 AM
I am not sure why exactly you want to do this but what you want is this...
Because your values for x & y are changing and you can't draw your line until you know both values you need to store them somewhere - and one method is in an array as I have done above.
Another way would be to PUT the values into a buffer and then GET them when you need them...
DIM x [] DIM y [] For k=1 TO 2 x= 5 * k y = 10 * k NEXT k line2 x[1],y[1],x[2],y[2]
Because your values for x & y are changing and you can't draw your line until you know both values you need to store them somewhere - and one method is in an array as I have done above.
Another way would be to PUT the values into a buffer and then GET them when you need them...
x = 0 y = 0 For k=1 TO 2 x= 5 * k y= 10 * k PUT x,y NEXT k line2 GET(NSP)Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-19 11:24 AM
2014-12-19
11:24 AM
Hey Barry, thanks !
It works.
Quick question - if I would like to use for several times sets of x,y values can I use the PUT GET buffer system of only the array method ?
For the moment it looks like for me that after using once the value from buffer it is deleted from there...
In other words is it poosible to do this ? :
It works.
Quick question - if I would like to use for several times sets of x,y values can I use the PUT GET buffer system of only the array method ?
For the moment it looks like for me that after using once the value from buffer it is deleted from there...
In other words is it poosible to do this ? :
x = 0 y = 0 For k=1 TO 2 x= 5 * k y= 10 * k PUT x,y NEXT k line2 GET(1), GET(1), GET(1), GET(1) ! ----- First line x1, y1, x2, y2, line2 0, 0, GET(1), GET(1) ! ----- Second line 0,0, x1, y1 line2 GET(1), GET(1), 0,0 ! ----- Third line x2, y2, 0, 0
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-19 11:35 AM
2014-12-19
11:35 AM
Hy,
GET will give you a value from the buffer removing it,
USE will acces the value but not delete it from the buffer.
In your case the array method is much more efficient because the buffer is a first in first out container and you can't read the second number without reading the first one.
GET will give you a value from the buffer removing it,
USE will acces the value but not delete it from the buffer.
In your case the array method is much more efficient because the buffer is a first in first out container and you can't read the second number without reading the first one.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-19 12:40 PM
2014-12-19
12:40 PM
Ilder wrote:And this the answer to my next question, thanks !
Hy,
In your case the array method is much more efficient because the buffer is a first in first out container and you can't read the second number without reading the first one.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-19 01:11 PM
2014-12-19
01:11 PM
GET will take the value from the buffer so it can only be used once.
However USE will leave the value in the buffer so it can be used again.
The problem is the buffer values must be used in the order that they are put in there.
So you would have to use some values, then use them again and discard them to use the next values that you need - could get very messy.
This is where the array is much better.
The values are stored in the array and can be used over and over and you can pick and choose easily which values you want to use.
However USE will leave the value in the buffer so it can be used again.
The problem is the buffer values must be used in the order that they are put in there.
So you would have to use some values, then use them again and discard them to use the next values that you need - could get very messy.
This is where the array is much better.
The values are stored in the array and can be used over and over and you can pick and choose easily which values you want to use.
DIM x [] DIM y [] For k=1 TO 2 x= 5 * k y = 10 * k NEXT k line2 x[1], y[1], x[2], y[2] ! ----- First line x1, y1, x2, y2, line2 0, 0, x[1], y[1] ! ----- Second line 0,0, x1, y1 line2 x[2], y[2], 0,0 ! ----- Third line x2, y2, 0, 0
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-19 01:14 PM
2014-12-19
01:14 PM
Ilder beat me to it.
I had a blackout just as I was about to post.
Barry.
I had a blackout just as I was about to post.

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-19 02:51 PM
2014-12-19
02:51 PM
Barry wrote:Electrical or neurological?
I had a blackout just as I was about to post.

David
David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC28 USA • Mac mini M4 Pro OSX15 | 64 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14
www.davidmaudlin.com
Digital Architecture
AC28 USA • Mac mini M4 Pro OSX15 | 64 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2014-12-21 02:54 AM
2014-12-21
02:54 AM

Power blackout fortunately.
Self induced blackouts might be on the cards though seeing as I am on my Christmas break now.

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11