Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

HtmlPanel - rich text on the device

Reply
 
LinkBack Thread Tools Display Modes
  #81 (permalink)  
Old 03-16-2011, 04:45 PM
Newbie
 
Join Date: Jul 2009
Posts: 7
Default

Good evening.

I am using Basic 4 PPC to build an application for Mobile Phones to act as a client to play MUD's. MUD's are text based multiplayer games (check more info in wikipedia, if you wish), and in resume clients to play those games are terminals that simply read and write text.
There are some protocols MUD server's use like colouring parts of text, that clients should be able to decypher. As I wanted to implement colours in my B4PPC MUD client, I realized I couldn't use text boxes to show coloured incoming text.
After a bit of search I've found out that HTML Panel should be the better solution to show incoming text, and so I did it. It runs ok on Desktop, and in my pocket device runs a little slower (is supposed to act this way).
The problem is that the more text it receives, the slower it becomes, and finally shoots an "Out of memory exception".

Two things before finishing the post:
- Usually, per each 10 lines of received text (like a paragraph, or so), considering I need to adjust it with HTML tags for changing font color multiple times, need to loop to read each character after special entities characters and adjust to proper HTML references, etc, incoming text ends up in HTML panel with something like 5 times bigger than when received.
- I know that if I receive a lot of text (I can fill a 50 page text document after playing a MUD for one hour) HTML text gets bigger and bigger. To avoid it, each time text reaches 6kb of text I erase first 3kb and just keep last 3kb, so I can still keep a small log of old text and not use too much memory

So why I still receive such exception?

Thanks in advance
Reply With Quote
  #82 (permalink)  
Old 03-16-2011, 05:32 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

It will probably be the bitmaps displayed in HtmlPanel that are causing the problem by running out of unmanaged graphics memory. Normally you should not do this but try calling GCCollect in the Hardware library each time you ShowHtml. The reason for trying this is explained in the "Bitmap memory overview" topic in the help for my ImageLibEx library.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #83 (permalink)  
Old 03-16-2011, 06:10 PM
Newbie
 
Join Date: Jul 2009
Posts: 7
Default

Thank you.
Going to try
Reply With Quote
  #84 (permalink)  
Old 03-16-2011, 10:50 PM
Newbie
 
Join Date: Jul 2009
Posts: 7
Default

Still need to try.

Two questions arised meanwhile:
- Is HTML panel the best solution for my intention? Text box would work faster for sure, but I couldn't use coloured text... Is there any other option?
- Please comment the following pseudo code, considering optimization (I believe that stills too slow and probably can run faster with some optimization), that is what happens when my app receive text (example):

TEXT RECEIVED:
- "The sun shines brightly in the [1;33meastern[0m sky."
MMC (my app)
- Receives the text in buffer() ("length=stream.ReadBytes(buffer(),4096)")
- Loops all bytes in search for Telnet protocols codes (it always start with byte 255 followed by two bytes more)
- Transform bytes to string (text=stream.BytesToString(buffer(),0,counter))
- Loop again all chars in search for special characters (like ", &, line breaks, etc), and when find one substitutes it for the corresponding HTML syntax (" for &#34 ; or line break for <br/>). Also when find ANSI color syntax, like the "[1;33m" (to put yellow color) and "[0m" (to return to standard color) in the previous example, substitutes it by "</font> <font color='yellow'>eastern</font><font color='white'>"
- Adds start HTML tag ("<HTML><font bgcolor='black' color='white'>") and end tag ("</font></HTML>") to the previous changed text
- Adds the resulting text to previous text already received
- Html.showHtml (resultingText)

I can only see one optimization at the starting point, when the app does a loop/substitution in all bytes received, then a new loop to change bytes to string, then a new loop on all string chars/substitution. Better do every change in bytes and then do bytesToString (will then be a code harder to read/maintain), do immediately bytesToString and all substitutions then (I tried this before but was having some troubles tracking byte 255 and escape char), or keep it this way?

Thank you in advance (once again)

Best regards
Reply With Quote
  #85 (permalink)  
Old 03-17-2011, 09:15 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

If you want coloured text on a device the only two ways of doing it are with the HtmlPanel or the WebBrowser libraries.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #86 (permalink)  
Old 03-17-2011, 05:51 PM
Newbie
 
Join Date: Jul 2009
Posts: 7
Default

Both just read html, right?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Centering text in a text box or label joel2009 Questions (Windows Mobile) 4 02-25-2009 02:53 PM
Text an einen bereits bestehenden Text "anhängen" JOTHA German Forum 7 09-12-2008 01:08 PM
Label/Text Control text centering TWELVE Basic4ppc Wishlist 1 06-04-2008 03:20 PM


All times are GMT. The time now is 06:45 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0