Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38935

Loop and move within boundary "interval logic for cursored list"

Newsgroups comp.lang.javascript
Date 2020-10-13 13:46 -0700
Message-ID <3aa3cfef-d2c4-4108-9eb4-af4df1819619o@googlegroups.com> (permalink)
Subject Loop and move within boundary "interval logic for cursored list"
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


I have a problem of writing out interval, it may be it actually need two loops to do what i want "could be but".

There is a list with items, named moveText with x row length. There is a cursor movenumber that "should be able to move within list". The max number of rows in moveText 41, so if it is bigger then 41, we have to move startpoint of list back by 41 seem logical. The following code below do that correct when move forward, and else we should start draw at element 0 because all elements fit in list. How ever using moveNumber the cursor as loop endpoint isn't ideal because you want to see all items "even those after cursor" when list is less then 41.

When list is less then 41 rows.

function drawTxtMove(){
	for (var i=drawStart;i<moveNumber;i++){
		ctm.fillStyle=tColor;
		ctm.font = "bold 17px serif";
		ctm.fillText(moveText[i], 9, 63+tSize);
		tSize=tSize+17;
		if(tSize>780){tSize=0;wSize=wSize+58;}
	}
	if (moveNumber>41) {drawStart=moveNumber-41;} else { drawStart=0;}
	tSize=0;
}

I had an idea, using some sort of extra term that switch between movenumber and moveText.length as delimiter for list depending on list length.

drawlimit=0;
function drawTxtMove(){
	for (var i=drawStart;i<drawlimit;i++){
		ctm.fillStyle=tColor;
		ctm.font = "bold 17px serif";
		ctm.fillText(moveText[i], 9, 63+tSize);
		tSize=tSize+17;
		if(tSize>780){tSize=0;wSize=wSize+58;}
	}
	if (moveText.length>41) {
			drawStart=moveNumber-41;
			drawlimit=moveNumber;
	} else { 
			drawStart=0;
			drawlimit=moveText.length;
	}
	tSize=0;
}

But for some reason when you back list and drawlimit becomes less then zero, drawatart some startrows become undefined

I thought i programmed when moveText.length<=42 drawStart should be 0, but apparently not. 

I must solved this type of problems 10th of times,but right now i just do not see what go wrong with boundary.

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-13 13:46 -0700
  Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-13 14:01 -0700
  Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-13 14:09 -0700
    Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-13 15:05 -0700
      Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-13 18:07 -0700
        Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-13 18:22 -0700
          Re: Loop and move within boundary "interval logic for cursored list" luserdroog <luser.droog@gmail.com> - 2020-10-13 20:36 -0700
            Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-14 01:34 -0700
              Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-14 01:37 -0700
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-14 01:38 -0700
                Re: Loop and move within boundary "interval logic for cursored list" luserdroog <luser.droog@gmail.com> - 2020-10-14 10:51 -0700
                Re: Loop and move within boundary "interval logic for cursored list" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-15 18:03 +0100
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-16 03:19 -0700
                Re: Loop and move within boundary "interval logic for cursored list" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-16 19:30 +0100
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-16 12:36 -0700
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-16 19:25 -0700
              Re: Loop and move within boundary "interval logic for cursored list" luserdroog <luser.droog@gmail.com> - 2020-10-14 10:32 -0700
            Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-14 02:32 -0700
              Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-14 02:40 -0700
            Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-14 05:05 -0700
              Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-14 05:16 -0700
          Re: Loop and move within boundary "interval logic for cursored list" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-15 18:03 +0100
            Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-15 13:05 -0700
              Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-15 14:58 -0700
              Re: Loop and move within boundary "interval logic for cursored list" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-16 19:14 +0100
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-16 19:23 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-17 11:05 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-17 03:07 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-17 14:47 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-17 05:59 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-17 15:21 +0200
                Re: Loop and move within boundary "interval logic for cursored list" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-17 15:09 +0100
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-17 11:11 -0700
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-19 01:52 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-19 13:37 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-19 05:08 -0700
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-19 05:11 -0700
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-19 05:52 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-19 19:15 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-19 11:01 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-20 15:30 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-20 07:26 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-21 00:01 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-20 18:19 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-21 13:01 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-21 15:07 -0700
                Re: Loop and move within boundary "interval logic for cursored list" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-22 01:21 +0200
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-20 07:31 -0700
                Re: Loop and move within boundary "interval logic for cursored list" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-19 18:04 +0100
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-19 10:47 -0700
                Re: Loop and move within boundary "interval logic for cursored list" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-19 19:33 +0100
                Re: Loop and move within boundary "interval logic for cursored list" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-19 16:36 -0700
                Re: Loop and move within boundary "interval logic for cursored list" Scott Sauyet <scott@sauyet.com> - 2020-10-20 13:36 -0700

csiph-web