Hi,
I have a little request - or maybe I am missing something obvious... EsString>>subStrings: currently treats two consecutive delimiters as if it were one. This is okay for many cases, but not for all. I have an example where I receive error messages from an interface that comes delimited with pipe-symbols. Each part of the string is a part of the message, and many messages come concetenated into one big string. The easiest thing to do would be to use subStrings: $| But I can't. I need the sixth part of every message to display it to the user, so what I tried was somthing like this: parts := returnString subStrings: $|. 6 to: parts size by: 6 do: [:idx| messages add: (parts at: idx)]. Unfortunately, if one of the parts of a message is empty (consist of two consecutive pipes), this doesn't work any more, because subStrings returns one part less for each pair of consecutive pipe symbols. So all messages after the one with an empty part are incorrect and consist of some other part of the message... For now, I will just add another extension method to EsString that leaves out the line marked in red below, but I think what should be done is add a method subStrings:skipEmpty: that is called by subStrings: with true (to preserve existing behavior) and in subStrings:skipEmpty: we should only skip Delimiters if the Boolean is true. Do people think this would be helpful? Would Instantiations consider adding this to VAST? Or is there such functionality already? Joachim subStrings: separators "Synopsis Answer an array containing the substrings in the receiver separated by the elements of @separators. Definition: <readableString> Answer an array of strings. Each element represents a group of characters separated by any of the characters in @separators. Parameters separators <sequencedReadableCollection> uncaptured Return Values <Array> unspecified Errors If @separators contains anything other than Characters. Implementation Notes The CLDT protocol says @separators is a single Character while the ANSI protocol says it is a collection of Characters. This implementation supports both protocols. Consecutive separators are treated as a single separation point. Leading or trailing separators are ignored." | answer startIndex endIndex delimiters | answer := OrderedCollection new. delimiters := separators isCharacter ifTrue: [ Array with: separators ] ifFalse: [ separators ]. startIndex := 1. [ startIndex <= self size ] whileTrue: [ endIndex := self findDelimiters: delimiters startingAt: startIndex. startIndex < endIndex ifTrue: [ answer add: (self copyFrom: startIndex to: endIndex - 1) ]. startIndex := self skipDelimiters: delimiters startingAt: endIndex ]. ^ answer asArray You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/hrznIdIWmmgJ. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Use String>>allSubStrings:
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Hey Marten,
that was fast ;-) Thanks! Am Dienstag, 16. Oktober 2012 11:05:07 UTC+2 schrieb Marten Feldtmann: Use String>>allSubStrings: You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/ecL3blWW4h4J. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Hey Marten, -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Phhhh, who reads the Migration Guide
before .... only afterwards :-)
Marten Am 16.10.2012 15:37, schrieb Sebastian Heidbrink:
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
I read the migration guide before but I did not care for #allSubstrings: and made my own method looking like #allSubstrings: :o)
Klaus Am Dienstag, 16. Oktober 2012 15:51:06 UTC+2 schrieb Marten Feldtmann: -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/YrcDCrLKPGYJ. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
I confess, I didn't read it when I was searching for my bug which got all messages from no. 431 on wrong ;-)
But I guess my question was so stupid that I really asked for a RTFM ;-) Joachim, glad to have found a simple solution Am Dienstag, 16. Oktober 2012 16:16:16 UTC+2 schrieb Klaus Breker: I read the migration guide before but I did not care for #allSubstrings: and made my own method looking like #allSubstrings: :o) You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/MM2EeMQsj0YJ. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
In reply to this post by jtuchel
Hi J
I had a similar problem during porting code from 5.5. replacing allSubStrings: wouldn't work for me, I wasn't going to sift through 700 000 lines of code to find everywhere to replace, even with advanced search. I simply edited EsString/String and replaced subString with the one from 5.5. My app works now, but, I probably need to find time to do the tedious work of making my app work with newer VAST. Sigh. Just my 2c Dusty On Tuesday, 16 October 2012 11:02:27 UTC+2, [hidden email] wrote: Hi,-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/mSWKiUiaRTAJ. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Hi Dusty,
in today's VA ST, the Refactoring Browser ships with the environment, including the rewrite rule engine. This is exactly the tool you'd need for such a task. The only thing that Instantiations should improve is that Refactoring should be loaded into an empty image by default - including the MED RB Extensions which turn most Browsers into Refactoring browsers... Joachim Am Mittwoch, 17. Oktober 2012 09:57:42 UTC+2 schrieb Dusty: Hi J-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/hsCySlDd-XsJ. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Free forum by Nabble | Edit this page |