Moving axis

• 02-25-2011
Eman500
Moving axis
I'm having real trouble in finding a way of moving an axis relative to a fixed point. The axis will represent different lengths in metres. The fixed point is a marker indicating the the length.

length
|
====100====200====300====400====500====600====700

This is what i need it to look like except i need the numbers to not be visible after these points i.e if the length changed to 300, 100 and 200 would not be visible anymore but 800 and 900 would be.

The length is being read from a file as a string and the counter changes every 0.5seconds

Thanks
• 02-25-2011
Babkockdood
Dood, I've barely an idea of what you're asking.

Post some source code maybe? Maybe tell us the big picture you're trying to accomplish?
• 02-25-2011
quzah
Code:

```void display( int offset, int width ) {     /* ?= N ===== N =? */     int x = 0;     /* prepadding */     for( x = offsest % 5; x > 0; x-- )         putchar( '=' );     printf( "%d", 10 * offset++  );     for( x = 0; x < 5; x++ )         putchar( '=' );     printf( "%d", 10 * offset++  );     /* postpadding */     for( x = (offsest + width) % 5; x > 0; x-- )         putchar( '=' ); }```
I think that's the general idea of what you're trying to do. Now naturally you'd want to use some looping in the center if you had a different amount of repeating to do there of your complete segments.
Quote:

Originally Posted by Babkockdood
Post some source code maybe? Maybe tell us the big picture you're trying to accomplish?

He's basically trying to display a floating window of text. Consider a string that is the alphabet: "abcdefghij...z". You want to display 5 characters at a time, at any given spot on that string.
Code:

`printf("%5s", alphabet + (offset > 21 ? 22 : offset < 0 ? 0 : offset) );`
That should give you a five character chunk of your alphabet string, based on whatever offeset you want to start on, without running off each end.

Quzah.