The great resource for OO-Basic programming is Andrew Pitonyak's "OpenOffice.org Macros Explained". In there is a lot of help on all aspects of ooBasic programming including String functions such as split() which along with trim() seems appropriate to your task. Thanx - John S
-----Original Message----- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Jonathan Kaye Sent: Monday, February 11, 2008 11:13 AM To: [email protected] Subject: [api-dev] Re: the meaning of "=" Steffen Grund wrote: > Hello, > > I am not the Basic expert here, but wouldn't something like this work? > While [etc] > and just initialize Position before, so it does not have the exit value? > > Hi Steffen, In fact, no it wouldn't. I'm processing entries in a spreadsheet which may have an arbitrary number of spaces in them. The entries also contain numbers. The idea is that all the numbers within a given chunk have to wind up at the end of the chunk next to a following space or EOL. So the exit condition would be when there are no more spaces left in the entry. I do this by successively shrinking the value of ProcessString with each loop. The actual code I wrote looks like this: Function cutspace(ProcessString) as String Dim i As Integer Dim Position As Integer Dim Chunk As String Dim Res As String Dim Lft As String While Instr(ProcessString, " ") Position = Instr(ProcessString, " ") Chunk = mid(ProcessString, 1, Position - 1) 'chunk up to space Res = mid(ProcessString, Position + 1, 999) 'from after space to end Lft = Lft + movetones(Chunk) + " " ProcessString = Res Wend ProcessString = Lft + movetones(Res) cutspace=ProcessString end Function Pretty ugly, eh? Cheers, Jonathan -- Registerd Linux user #445917 at http://counter.li.org/ Please do not send me copies of list mail. I read the lists. Thanks! --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
