visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
316 experts, 1194 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Delphi :: list of numbers


By: progGoon U.S.A.  Date: 09/02/2003 00:00:00  English  Points: 120 Status: Answered
Quality : Excellent
want to create a sliding window simulation. In order to do this the user specifies the range of nos (eg. 0 - 8) so the list would appear 0,1,2,3,4,5,6,7.

Then the user wouls specify the amount of frames they would like to send. eg. 3

This should affect the list, so it should look like

3,4,5,6,7,0,1,2.

Where the head of the list goes to the back.

Not sure how to store these numbers and how to implement this?!

cheers
By: VGR Date: 09/02/2003 00:30:00 English  Type : Comment
the simplier solution is this :
you memorize your array 0,1,2,3,4,5,6,7 and you keep track of an index (Byte?) on the current element. In your case , three.
Now when you parse your array, you start at the index and then get the "next" element, the index of the "next of i" being (i+1)MOD 8

easy
By: progGoon Date: 09/02/2003 03:21:00 English  Type : Comment
need more help in creating code.

Can create the array but not sure of the method of indexing then re-aranging the array.

eg,

array of 5, 0,1,2,3,4

and user selects 2.

Want the array to display

2,3,4,0,1. So the first two go to the back
By: VGR Date: 09/02/2003 03:53:00 English  Type : Answer
[declarations]
const cMax = 10; // 255 Mmaximum
type myTab = array[1..cMax] of Byte;
Var theTab : myTab;
tabSize : Byte; // user choice
index : Byte; // user choice
i : Word; // loop counter

// warning, uses the global variable tabSize
Function NextIndex( i : Byte) : Byte;
Begin
NextIndex:=(i+1) MOD tabSize;
End; // NextIndex Byte Function

[code here]
// simulation of filling of the base array
tabSize:=8;
for i:=1 to tabSize Do myTab:=i-1; // 0..tabSize-1

// here actual display depending on the position of the chosen position (let's say, 5 )
index:=5;
For i:=index to index+tabSize Do
Begin
// display myTab
WriteLn('element ',i,' is ',myTab);
i:=NextIndex(i);
End; // For tabSize elements
By: progGoon Date: 09/02/2003 03:58:00 English  Type : Comment
superb, cheers buddy
By: VGR Date: 09/02/2003 04:08:00 English  Type : Comment
not even a typo ? How surprising given I wrote this with no testing :D
I'm getting better with age :D
By: progGoon Date: 09/02/2003 04:17:00 English  Type : Comment
were a few typos!!!(sorry) just implementing it now. Only needed a vague idea of how to do it and luckily u showed me!

cheers mate

Do register to be able to answer

EContact
browser fav
page generated in 247.898100 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page