pageup/pagedwn implementation

Hi all, I am looking for some sample code which shows how to implement pageup/ pagedown feature using C language similar to the ones we encounter in our mobile devices.In mobiles if we dont have enough view space to show entire content of single message,we provide the feature to do key up/key dn or pageup/pagedn.I have tried a similar code here given below,I would appreciate if some one could give me sample code or links regarding implementing this feature in embedded devices using C language only.

#include #include "string.h"

void pageup(); void pagedown(); static int pagecounter=0; int bytesperpage=161; int numpages=0; int contentremaining=0; char* customstringcopy=NULL; char arr[161]={0}; int main(int argc, char *argv[]) { int totlen=0; int pagenum=0;

char* customstring=NULL;

char* data="Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collec."; char* stringdata="Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as it's compiler. Dev- C++ can also be used in combination with Cygwin or any other GCC based compiler."; char* stringdata1="the #bloodshed channel has recently been created on the Undernet IRC server. I will be please to talk with you there so feel free to join :) If you want have an IRC client you can get one for Windows at mirc.com and for Linux at xchat.org"; char* stringdata2="You can subscribe to the Dev-C++ mailing list (for asking and answering questions on Dev-C++ and C/C++ programming) by clicking here and filling out the subscribe form there.";

totlen=strlen(stringdata)+strlen(stringdata)+strlen(stringdata2); printf("total length is %d\n",totlen); printf("length of data is %d\n",strlen(data) ); customstring=(char*)(malloc)(totlen+4); customstringcopy=customstring; memset(customstring,0,totlen+4);

memcpy(customstring,stringdata,strlen(stringdata)); customstring=customstring+strlen(stringdata); customstring[0]='\n'; customstring++; /*printf("%s\n",stringdata); printf("%s\n",customstringcopy);*/

/*customstring[0]='\n'; customstring++;*/

memcpy(customstring,stringdata1,strlen(stringdata1)); customstring=customstring+strlen(stringdata1); customstring[0]='\n'; customstring++; /*printf("%s\n",stringdata1); printf("%s\n",customstringcopy);*/

memcpy(customstring,stringdata2,strlen(stringdata2)); customstring=customstring+strlen(stringdata2); customstring[0]='\n'; customstring++; /* printf("%s\n",stringdata2);*/ printf("%s\n",customstringcopy);

numpages=totlen/bytesperpage; printf("total number of pages is %d\n",numpages); contentremaining=(totlen)%(bytesperpage); if(contentremaining > 0) { numpages=numpages+1;

} printf("total number of pages is %d\n",numpages); for(pagenum=0;pagenum0;pagenum--) { pagedown(); } system("PAUSE"); return EXIT_SUCCESS; }

void pageup() {

if(pagecounter1) { pagecounter--; printf("pagecounter value is %d \n",pagecounter); customstringcopy=customstringcopy-(bytesperpage); memcpy(arr,customstringcopy,161); printf("%s\n\n",arr); }

} /* if(pagecounter>0) {

customstringcopy=customstringcopy- bytesperpage; memcpy(arr,customstringcopy,161); printf("%s\n\n",arr);

} */

}

Looking farward for your replies and advanced thanks for the same, Regards, s.subbarayan

Reply to
ssubbarayan
Loading thread data ...

I don't think you'll get much help here. First off, no one is going to wade through that code finding bugs for you - that's *your* job, and the job of your colleagues. Secondly, it doesn't look like a hard task - if you can't get this right, you're in the wrong job.

However, I'll give you some free general advice. The compiler doesn't care what your code looks like, but other people (including yourself)

*do* - write legible code!

The biggest step here is to find the "space" bar - it's the great big key at the bottom of your keyboard. When writing text (such as these posts), there should always be two spaces at the end of a sentence, and one after other punctuation (such as a comma).

In C, put spaces around operators (except "*", "&", "++" and "--"), after commas, and after keywords (but not after an open bracket, or after a function name). There are a few variations in style rules, but these examples show a reasonable set:

memset(customstring, 0, totlen + 4); customstring = customstring + strlen(stringdata1); for (pagenum = 0; pagenum

Reply to
David Brown

You'd be surprised how often people here *do* wade through the code finding bugs for OPs...

Perhaps. But first they have something else to get right...

Yes. I took one look and thought "let someone else do that one". If I want to look at obscure code, I can go and read IOCCC entries.

--
Richard Heathfield 
Email: -http://www. +rjh@
Google users: 
"Usenet is a strange place" - dmr 29 July 1999
Reply to
Richard Heathfield

Not wanting to get into a style war (but what better place than c.l.c. for that?), but spaces after open brackets are fantastic. Instead of:

try using:

memset( customstring, 0, totlen + 4 ); customstring =3D customstring + strlen( stringdata1 ); for( pagenum =3D 0; pagenum it's much easier to read.

But I certainly agree with David that those long mono-case names are atrocious. Break up the words with underscores, for the love of Bob!

-- William Pursell

Reply to
William Pursell

And do note that if you think you can read you code, because after all you've written it yourself - consider what will happen when you come back to that program half a year from now, to add another option.

Wrong. Two spaces after a full stop is a habit in the USA, where people didn't learn to write until the typewriter was invented and haven't got any more culture since we started using word processors. In the civilised world, it's one full stop, one space.

Richard

Reply to
Richard Bos

...

suggests a much more complicated history, one that is incompatible with yours (and completely lacking in ridiculously stupid gratuitous insults). If you know that the Wikipedia history is inaccurate, I'd recommend making some edits.

Reply to
jameskuyper

No, two spaces after a full stop is a habit for good typewriting style in all Latin alphabet languages (including American as well as English). It comes from the simple fact that when reading, there is a longer pause at the end of a sentence than for punctuation within a sentence. With good typesetting, the space after a period is not exactly twice the space between words (in particular, it should be more "stretchy" when justifying text), but it's the best you can do with a fixed-width font.

Using just one space after a full stop is a habit from when amateurs started using computers with word processors and produced ugly and inconsistent documents instead of leaving the work to professionals.

Have a read of the TeX Book - just because it is written by an American, doesn't mean it's wrong!

(And I know using a hyphen with spaces is bad typography, but ASCII doesn't have an en-dash - you can blame *that* one on Americans if you like.)

Reply to
David Brown

... snip ...

Actually, IMO you should put the space after the 'for'. for is NOT a function name, and this practice distinguishes functions from reserved words or functional macros. It also avoids any need for a space AFTER the '('.

This makes the above appear as:

for (pagenum = 0; pagenum

Reply to
CBFalconer

... snip ...

I mildly disagree. However, I do abhor people who can't insert at least one space after a punctuation mark.

Incidentally, anything done to clarify typewritten verbiage certainly applies to Usenet. Why do rabid classicists want to reduce the accuracy of reading? :-)

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.
Reply to
CBFalconer

I was taught in typing class that a dash is typed as "--" (two adjacent hyphens)..

--
Grant
Reply to
Grant Edwards

I'm not sure about rabid classicists, but I think some Usenet posters (particularly various net.kooks) try subconsciously to reduce the accuracy of reading as a means to mask the low quality of the content: the more nonsensical the ideas being presented, the worse the formatting seems to get. Perhaps it's not causal, but there seems to be a correlation...

Reply to
Grant Edwards

People that have a hard time communicating in written form will have content problems, as well as syntax and form problems. It is because of lack of ability, not attempts to cover up lack of content.

stonerfish

--
It takes one to know one.
Reply to
jellybean stonerfish

That's a common practice, and fine on a typewriter with long enough hyphens, or if it can do half-spacing - that lets you simulate a decent em-dash. When it's just two hyphens, I think it looks a bit broken, and prefer the space-hyphen-space as the least bad choice.

formatting link

Reply to
David Brown

I tend to adopt the same convention, that is a space after an if, while etc but not after a function name. However I long since learned that it isn't worth arguing such points because you never get anywhere. If you were to be pedantic you could easily argue that I'm inconsistent because I don't use a space after sizeof - this reflects my view of sizeof as a pseudofunction rather than a proper language construct like the other keywords.

The only really important things are that usage is at least reasonably consistent, there is enough whitespace in there somewhere that you can see the structure of the code, and in particular that indentation is not actively misleading.

--
Andrew Smallshaw
andrews@sdf.lonestar.org
Reply to
Andrew Smallshaw

A page that starts by pointing out that its own title is actually wrong? Why should I assume that anything else on it is correct?

Meanwhile, I do actually own books in at least six languages, and some time ago I made the effort of actually _checking this_. Gosh, wow, facts intruding in a discussion. How gauche... but nevertheless, I did. Only three books did have two spaces after a full stop, and those were "typeset" in either troff or TeX - and the rest of the typography was just as dire. (Yes, K&R2 was one. If only they'd gone to the effort of making the design of their book read good as the text.) All other books I own - from six different countries at least, from dates throughout last century and even before - do not have these double spaces. In some cases, it may look as if they did, but if you take the trouble of measuring it (remember that famous programming adagium? Don't rely on guesswork, _measure_!) it becomes clear that this is a visual deception, most likely due to the capital which starts the next sentence not being kerned. Do the test: open a random book with real (_not_ troff) typography, and check the difference between ". R" and ". A" or ". T". You'll notice a _visually_ larger gap between the latter than between the former. If you put a ruler next to them, though, you'll see that the space is the same, and it's only the extra internal white in the A and T which makes it look larger.

Why engage in such a futile exercise? Let the facts speak for themselves, and let the Pikiwediasts argue amongst themselves.

Richard

Reply to
Richard Bos

Then do please explain why I've hardly ever seen anyone but a USAlien advocate double spacing full stops, and _never_ anyone in any other language but English.

Simply wrong. Professionals (and yes, I work for a publisher, so I know a handful of those) never use two spaces - at least, not outside the USA.

Richard

Reply to
Richard Bos

The title is "Double spaced sentences". That title makes no assertions, and correctly describes what the page is about. What are you talking referring to?

The URL for that page ends in French_spacing. One of the first things the page discusses is the fact that the term "french spacing" has become a popular term for double spacing, despite being historically inaccurate. Is that what you're referring to? But French_spacing isn't the title - it's the URL.

As a general rule, I find that texts which contain such disclaimers tend to be more accurate than those which do not. Such disclaimers usually indicate someone paying more than the usual amount of attention to detail.

However, I wouldn't recommend assuming that anything that article says is correct; any more than you should make that same assumption about any other source of information. If you have any interest in the subject, and doubts about the accuracy of that article, I'd recommend following the traditional approach to verifying the accuracy of that article, by tracking down the citations in the bibliography. There's 67 of them, plenty to choose from.

The main conflict between your brief statement and the wikipedia article is that you claim double spacing as an American habit; presumably one we still practice, though you're not entirely clear on that point. The wikipedia article identifies double spacing as a British invention that has since gone out of style, even in Britain. Since "habit" and "invention" are two very different things, even that conflict is less than perfectly clear.

The wikipedia article identifies the invention of the typewriter as a key event in the adoption of this practice; you mention the typewriter, but it's not entirely clear whether you're implying a causal connection, or merely mentioning it as part of your tirade about how stupid Americans are.

Relevant evidence for distinguishing between your assertions and the ones made in the Wikipedia article would have to distinguish between British and American texts, would have to include both typeset and typewritten texts, and would have to include typeset texts from before the typewriter was invented. I couldn't check this out using my book collection; while it includes about 2000 books, almost all of them were typeset in the US, and all of them were typeset after the invention of the typewriter. Books typeset before that invention are mostly collector's items, and I'm not that type of a collector. The sample I've looked at this morning didn't include any with double spacing after sentences, which provides no support for your assertion that this is an American habit.

The evidence you describe involves only typeset books, does not distinguish American and British sources, does not distinguish between texts written before and after the invention of the typewriter. It's not a very useful study for resolving this issue.

Reply to
James Kuyper

That will tell you about the books you happen to have, not about the history of this notion. To verify that it is not a fiction, you need to have a book in English, published in the UK or the USA, sometime between roughly the middle of the 19th and 20th centuries. The only two I have to hand are an OED (1955 reprint of the 1933 edition) and a Shakespeare (1903 but reset in 1943). Both show the fashion for wider space after a full stop, though not the "full quad" suggested by typographers of the late 19th century.

The habit got incorporated into typing simply because it was in fashion when typing started. I can't say anything about French habits at that time since I don't have books published in France at the right date.

--
Ben.
Reply to
Ben Bacarisse

Nobody claimed that the "two spaces after a full stop" applied to typeset material. It was a rule meant for typewritten material where there was only a single, fixed-width, space.

--
Grant Edwards                   grante             Yow! I have the power to
                                  at               HALT PRODUCTION on all
                               visi.com            TEENAGE SEX COMEDIES!!
Reply to
Grant Edwards

However, let me point out that Usenet messages, written according to the appropriate protocols, are using fixed width fonts with fixed width spaces. The critical thing is not the 'typewriter', but the physical appearance of the end product.

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.
Reply to
CBFalconer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.