Languages :: Delphi :: list of numbers |
|||
| By: progGoon |
Date: 09/02/2003 00:00:00 |
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 | 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 | 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 | 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 | Type : Comment |
|
| superb, cheers buddy |
|||
| By: VGR | Date: 09/02/2003 04:08:00 | 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 | 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 |
|||
©2012 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








