Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Trim Spaces from Beginning and end of Strings


Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 03-24-2008, 08:51 AM
Senior Member
 
Join Date: Mar 2008
Posts: 114
Default

For what its worth, I also use a custom made trim, as follows (also employs / also you can use) left / right functions ...

Quote:
Sub Left(left_mystr,left_length)
If left_mystr = "" Then Return
Return SubString (left_mystr,0, left_length)
End Sub
Sub Right(right_mystr,right_length)
If right_mystr = "" Then Return
Return SubString (right_mystr, StrLength (right_mystr) - right_length, right_length)
End Sub

Sub Trim(trim_str)
Do Until StrCompare(Left(trim_str,1)," ") <> 0
trim_str = SubString(trim_str,1,StrLength(trim_str)-1)
Loop
Do Until StrCompare(right(trim_str,1), " ") <> 0
trim_str = left(trim_str,StrLength(trim_str)-1)
Loop
Return trim_str
End Sub
I must admit though, processing time is an issue ... I load in a 16k Scott adams data format file (contains saved integers and strings) and, in the compiled version of my game it takes about :

app compiled for and running on PC 0.5 - 1 second
app compiled on and running on ppc (rw6815) 10 seconds

... to load the data file into variables ...

Perhaps indeed the compiler can be tuned for better string manipulation?

I am now in the process of removing my trim / left / right functions (mid already removed) in place of the native str functions of b4p to see if this helps any as my original functions were used to a) help me converting my app from vb (convenient at the time and b) learning to use the foreign (to me) strindexof / substring etc ...

Last edited by badkarma : 03-24-2008 at 09:00 AM.
Reply With Quote
  #22 (permalink)  
Old 03-24-2008, 09:06 AM
Senior Member
 
Join Date: Mar 2008
Posts: 114
Default

Interestingly, I have just replaced my trim function with abastiens trim function, and it has shaved 2 seconds off the compiled ppc versions loading time (down now to 8 seconds from previous 10...) compiler obviously does not like jumping around functions which fiddle with strings too much when compiled and running on ppc...
Reply With Quote
  #23 (permalink)  
Old 03-24-2008, 01:02 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,687
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Try this small StringsEx library. It implements the native .NET whitespace Trim() method (amongst others) and so should be a lot faster. Should work with .NET 1.0 and 2.0 and on device and desktop. Sometime I'll write a help file and post it in the libraries forum but the included demo makes it obvious how to use it and what methods are included.
Attached Files
File Type: zip StringsEx1.0.zip (2.5 KB, 9 views)

Last edited by agraham : 03-24-2008 at 01:16 PM.
Reply With Quote
  #24 (permalink)  
Old 03-24-2008, 07:51 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,687
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Hugely enhanced StringEx library version 1.1 now posted, together with with a help file, in the libraries thread. http://www.basic4ppc.com/forum/showthread.php?p=10957
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling Problems - Images must not include spaces J12345T Bug Reports 8 06-01-2008 08:55 AM
esiste la funzione trim? marcomarco Italian Forum 2 04-16-2008 09:03 AM
SORT / TRIM Table(CSV) sintaq Questions & Help Needed 1 03-24-2008 10:52 AM
Remove spaces from string forisco Questions & Help Needed 2 11-16-2007 11:07 AM
Externalization of strings for localisation Tirs Questions & Help Needed 2 05-29-2007 11:19 PM


All times are GMT. The time now is 12:53 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0