Pharo-users
By thread
pharo-users@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
December 2014
- 70 participants
- 473 messages
Re: [Pharo-users] New Pharo user, some questions
by David Boeren
That's the next line of code after what I quoted:
"Parse the JSON data returned by the api"
data := NeoJSONReader fromString: response.
But, prior to the JSON parsing I was doing a couple of string replacements
to patch up the data. The system I'm moving the data into doesn't accept
accented characters or bullets, and it wants empty strings instead of nulls.
All the JSON stuff works fine. It's just the string operations
with copyReplaceAll:with: that aren't working as expected for some reason.
Or are you saying that the data I get from from asUrl retrieveContents is
not a "proper string" and maybe that's why it's not working?
On Wed, Dec 10, 2014 at 6:34 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>
> > On 10 Dec 2014, at 21:26, dboeren <boerend(a)gmail.com> wrote:
> >
> > "Fetch the raw JSON data from dtdb.co"
> > response := 'http://dtdb.co/api/cards/' asUrl retrieveContents
> asString.
>
> Why no do
>
> NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl
> retrieveContents
>
> ?
>
> You'll get the data back, nicely parsed and converted to proper Pharo
> strings.
>
> Sven
>
Dec. 11, 2014
Re: [Pharo-users] New Pharo user, some questions
by Hernán Morales Durand
2014-12-10 17:26 GMT-03:00 dboeren <boerend(a)gmail.com>:
> \u009e
\u00e9
Dec. 11, 2014
Re: [Pharo-users] New Pharo user, some questions
by Sven Van Caekenberghe
> On 10 Dec 2014, at 21:26, dboeren <boerend(a)gmail.com> wrote:
>
> "Fetch the raw JSON data from dtdb.co"
> response := 'http://dtdb.co/api/cards/' asUrl retrieveContents asString.
Why no do
NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl retrieveContents
?
You'll get the data back, nicely parsed and converted to proper Pharo strings.
Sven
Dec. 10, 2014
Re: [Pharo-users] New Pharo user, some questions
by Edward Povazan
Unfortunately, the iOS apps cannot mark memory as âexecutableâ so that prevents JIT.
On Dec 10, 2014, at 1:53 PM, kilon alios <kilon.alios(a)gmail.com> wrote:
> I cant answer your JSON question but I can answer the other two questions a) iOS b) Pharo video tutorial
>
> a) as far iOS is concerned, yes pharo runs fine on it. I am not so sure about the new vm Cog but there are 2 commercial pharo apps by the same developer on Apple Story one is called DrGeo , which is a very cool app for teaching kids and grown apps about geometry and iStoa which is another educational app. So yes pharo looks fine on iOS platform.
>
> b) about video tutorial , I am actually making a series of tutorial that I call "Pharo Video Tutorial" using Pharo 3 and now I am using Pharo 4 , I like to teach people the cutting edge and you can find a playlist with those tutorial here
>
> https://www.youtube.com/watch?v=Ol5ivaEATLQ&list=PLqbtQ7OkSta0ULYAd7Qdxof85…
>
> you can ommit the first one is about a general intro to pharo and the second which is how to install pharo , the rest are all 100% practical and I try to keep the blah blah to a minimum. Excluding the first hour you have a total of 3 hours cut down to 10 minutes more or less video tutorials that will give you a very solid introduction to Pharo. Is an ongoing effort so subscribe to be notified about new tutorials.
>
> On Wed, Dec 10, 2014 at 10:26 PM, dboeren <boerend(a)gmail.com> wrote:
> Now that my image is working properly again and the fires have been put out,
> I wanted to introduce myself a bit better...
>
> My name is David Boeren. I first learned Smalltalk back in college many
> years ago, we used Smalltalk V in an object oriented programming class I
> took which was first-half Smalltalk, second-half C++. This would be about
> 1992 I think? In recent years I've mainly been using Java, with occasional
> Python dabblings. I remember installing Squeak once or twice over the
> years, but to be honest it felt a bit clunky, perhaps this was just an early
> primitive version or whatever.
>
> Recently, I've been getting the itch to try out some different languages. I
> was kind of looking at Scala or Clojure, one co-worker suggested Erlang, and
> so forth. But after doing a brief review I ended up coming back to
> Smalltalk which even after all these years still stands right up with the
> cutting edge I think. Sure, there are a few things that I think would be a
> little different if it were designed today like tuple support or whatever,
> but it feels like the right choice for something I'm going to use mainly for
> "fun" projects and the interactive environment is awesome.
>
>
> One thing I wanted to ask about is the status of getting Pharo running on
> iOS (or at least iPad). I found some old posts but nothing much within the
> last couple of years. I know there were app store policy issues in the past
> but I think that Apple has opened things up a bit since then, you can now
> get Pythonista in the app store, or Codea. Is there still an obstacle or is
> it just something that hasn't been gotten around to yet? I'd love to get it
> running on my iPad Mini and be able to transmit code back and forth between
> there and my laptop to work on it wherever I'm at.
>
>
> Second, I'm running into an oddity and I'm not sure what I'm doing wrong or
> whether this is a bug of some sort, this has to do with trying to replace
> unicode characters in a string which seems like it should be a
> straightforward operation. Here is my code:
>
> "Fetch the raw JSON data from dtdb.co"
> response := 'http://dtdb.co/api/cards/' asUrl retrieveContents asString.
>
> "Clean up the data a bit to make it a little more regular"
> response := response copyReplaceAll: 'null' with: '""'.
> response := response copyReplaceAll: '\u2022' with: ','.
> response := response copyReplaceAll: '\u009e' with: 'e'.
>
> Basically I'm just pulling some JSON data and then doing a few string
> replacements to make the data suit my needs. The first one works. The
> second one works. Since the third one ALSO uses a \uXXXX code I would
> expect it to work too, but it does not - the accented characters are still
> there.
>
> To get a bit more visibility into this, I copied the CopyReplaceAll code
> from SequenceableCollection into a scratch class method and adding some
> Transcript output:
>
> copyReplaceIn: aString All: oldSubCollection with: newCollection
> "Answer a copy of the receiver in which all occurrences of
> oldSubCollection have been replaced by newCollection "
>
> | startSearch currentIndex endIndex |
>
> Transcript show: 'start' ; cr.
> startSearch := 1.
> [(currentIndex := aString indexOfSubCollection: oldSubCollection
> startingAt: startSearch) > 0]
> whileTrue: [
> Transcript show: 'Found at index ' ; show: currentIndex ; cr.
> endIndex := currentIndex + oldSubCollection size - 1.
> aString := aString
> copyReplaceFrom: currentIndex
> to: endIndex
> with: newCollection.
> startSearch := currentIndex + newCollection size].
> Transcript show: 'done' ; cr.
> ^ aString
>
> A minimal test seemed to work:
> HelloWorld copyReplaceIn: 'R\u00e9my Lapointe' All: '\u00e9' with: 'e'.
>
> start
> Found at index 2
> done
>
> Testing this with the real data worked too:
> HelloWorld copyReplaceIn: ('http://dtdb.co/api/cards/' asUrl
> retrieveContents asString) All: '\u00e9' with: 'e'.
> start
> Found at index 22379
> Found at index 22500
> done
>
>
> However, when I went back to using the regular copyReplaceAll:With: method
> it does not work and I'm not sure why. When it executes this:
> aString indexOfSubCollection: oldSubCollection startingAt: startSearch
>
> The value comes back as 0 even though it's the same data from
> 'http://dtdb.co/api/cards/' asUrl retrieveContents asString (I added a "self
> halt" to be able to step into the method and view the variable values), and
> I'm not sure what the difference is. There shouldn't be a limit on the size
> of the collection, should there? The whole thing is around 116k which is
> big but not ridiculously so. It is however big enough that the debugger
> can't show the whole value, or at least I haven't found a way to do so.
>
>
> And last, is there a good video tutorial for the Pharo beginner on how to
> use the various browsers, debugger, tools, etc... that come with Pharo? I
> would like to start learning more about the best ways to use these in my
> development processes. I'm also having a lot of trouble finding the correct
> classes and message for what I want to do, searching online w/ Google often
> seem to turn up outdated information (or for a different smalltalk flavor)
> and it can take a while to figure out the correct way to do things. Is
> there a good central reference for the APIs somewhere? I know that you can
> search in the browser but I usually don't know the name to search for. It
> would be good to have a handy reference detailing how to do all the
> commonplace stuff.
>
> Thanks!
>
>
>
> --
> View this message in context: http://forum.world.st/New-Pharo-user-some-questions-tp4795325.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>
Dec. 10, 2014
Re: [Pharo-users] New Pharo user, some questions
by kilon alios
I cant answer your JSON question but I can answer the other two questions
a) iOS b) Pharo video tutorial
a) as far iOS is concerned, yes pharo runs fine on it. I am not so sure
about the new vm Cog but there are 2 commercial pharo apps by the same
developer on Apple Story one is called DrGeo , which is a very cool app for
teaching kids and grown apps about geometry and iStoa which is another
educational app. So yes pharo looks fine on iOS platform.
b) about video tutorial , I am actually making a series of tutorial that I
call "Pharo Video Tutorial" using Pharo 3 and now I am using Pharo 4 , I
like to teach people the cutting edge and you can find a playlist with
those tutorial here
https://www.youtube.com/watch?v=Ol5ivaEATLQ&list=PLqbtQ7OkSta0ULYAd7Qdxof85…
you can ommit the first one is about a general intro to pharo and the
second which is how to install pharo , the rest are all 100% practical and
I try to keep the blah blah to a minimum. Excluding the first hour you
have a total of 3 hours cut down to 10 minutes more or less video tutorials
that will give you a very solid introduction to Pharo. Is an ongoing effort
so subscribe to be notified about new tutorials.
On Wed, Dec 10, 2014 at 10:26 PM, dboeren <boerend(a)gmail.com> wrote:
> Now that my image is working properly again and the fires have been put
> out,
> I wanted to introduce myself a bit better...
>
> My name is David Boeren. I first learned Smalltalk back in college many
> years ago, we used Smalltalk V in an object oriented programming class I
> took which was first-half Smalltalk, second-half C++. This would be about
> 1992 I think? In recent years I've mainly been using Java, with occasional
> Python dabblings. I remember installing Squeak once or twice over the
> years, but to be honest it felt a bit clunky, perhaps this was just an
> early
> primitive version or whatever.
>
> Recently, I've been getting the itch to try out some different languages.
> I
> was kind of looking at Scala or Clojure, one co-worker suggested Erlang,
> and
> so forth. But after doing a brief review I ended up coming back to
> Smalltalk which even after all these years still stands right up with the
> cutting edge I think. Sure, there are a few things that I think would be a
> little different if it were designed today like tuple support or whatever,
> but it feels like the right choice for something I'm going to use mainly
> for
> "fun" projects and the interactive environment is awesome.
>
>
> One thing I wanted to ask about is the status of getting Pharo running on
> iOS (or at least iPad). I found some old posts but nothing much within the
> last couple of years. I know there were app store policy issues in the
> past
> but I think that Apple has opened things up a bit since then, you can now
> get Pythonista in the app store, or Codea. Is there still an obstacle or
> is
> it just something that hasn't been gotten around to yet? I'd love to get
> it
> running on my iPad Mini and be able to transmit code back and forth between
> there and my laptop to work on it wherever I'm at.
>
>
> Second, I'm running into an oddity and I'm not sure what I'm doing wrong or
> whether this is a bug of some sort, this has to do with trying to replace
> unicode characters in a string which seems like it should be a
> straightforward operation. Here is my code:
>
> "Fetch the raw JSON data from dtdb.co"
> response := 'http://dtdb.co/api/cards/' asUrl retrieveContents
> asString.
>
> "Clean up the data a bit to make it a little more regular"
> response := response copyReplaceAll: 'null' with: '""'.
> response := response copyReplaceAll: '\u2022' with: ','.
> response := response copyReplaceAll: '\u009e' with: 'e'.
>
> Basically I'm just pulling some JSON data and then doing a few string
> replacements to make the data suit my needs. The first one works. The
> second one works. Since the third one ALSO uses a \uXXXX code I would
> expect it to work too, but it does not - the accented characters are still
> there.
>
> To get a bit more visibility into this, I copied the CopyReplaceAll code
> from SequenceableCollection into a scratch class method and adding some
> Transcript output:
>
> copyReplaceIn: aString All: oldSubCollection with: newCollection
> "Answer a copy of the receiver in which all occurrences of
> oldSubCollection have been replaced by newCollection "
>
> | startSearch currentIndex endIndex |
>
> Transcript show: 'start' ; cr.
> startSearch := 1.
> [(currentIndex := aString indexOfSubCollection: oldSubCollection
> startingAt: startSearch) > 0]
> whileTrue: [
> Transcript show: 'Found at index ' ; show:
> currentIndex ; cr.
> endIndex := currentIndex + oldSubCollection size -
> 1.
> aString := aString
> copyReplaceFrom: currentIndex
> to: endIndex
> with: newCollection.
> startSearch := currentIndex +
> newCollection size].
> Transcript show: 'done' ; cr.
> ^ aString
>
> A minimal test seemed to work:
> HelloWorld copyReplaceIn: 'R\u00e9my Lapointe' All: '\u00e9' with: 'e'.
>
> start
> Found at index 2
> done
>
> Testing this with the real data worked too:
> HelloWorld copyReplaceIn: ('http://dtdb.co/api/cards/' asUrl
> retrieveContents asString) All: '\u00e9' with: 'e'.
> start
> Found at index 22379
> Found at index 22500
> done
>
>
> However, when I went back to using the regular copyReplaceAll:With: method
> it does not work and I'm not sure why. When it executes this:
> aString indexOfSubCollection: oldSubCollection startingAt: startSearch
>
> The value comes back as 0 even though it's the same data from
> 'http://dtdb.co/api/cards/' asUrl retrieveContents asString (I added a
> "self
> halt" to be able to step into the method and view the variable values), and
> I'm not sure what the difference is. There shouldn't be a limit on the
> size
> of the collection, should there? The whole thing is around 116k which is
> big but not ridiculously so. It is however big enough that the debugger
> can't show the whole value, or at least I haven't found a way to do so.
>
>
> And last, is there a good video tutorial for the Pharo beginner on how to
> use the various browsers, debugger, tools, etc... that come with Pharo? I
> would like to start learning more about the best ways to use these in my
> development processes. I'm also having a lot of trouble finding the
> correct
> classes and message for what I want to do, searching online w/ Google often
> seem to turn up outdated information (or for a different smalltalk flavor)
> and it can take a while to figure out the correct way to do things. Is
> there a good central reference for the APIs somewhere? I know that you can
> search in the browser but I usually don't know the name to search for. It
> would be good to have a handy reference detailing how to do all the
> commonplace stuff.
>
> Thanks!
>
>
>
> --
> View this message in context:
> http://forum.world.st/New-Pharo-user-some-questions-tp4795325.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>
Dec. 10, 2014
Re: [Pharo-users] New Pharo user, some questions
by Edward Povazan
Hello,
Smalltalk has been on iOS for a while:
https://www.mobilewikiserver.com/Fraction.html
though the apps are by John McIntosh who did the initial port (I think).
I donât know if there is a formal way of making iOS apps with Pharo/Squeak.
I guess https://github.com/johnmci/Scratch.app.for.iOS would be a starting point.
I am in a similar boat as you are - Pharo is my playground for getting hard ideas done. Then I go back to ObjC when I know what I am doing.
Would really like to use Pharo day to day - one day!
Cheers,
-Ed
On Dec 10, 2014, at 12:26 PM, dboeren <boerend(a)gmail.com> wrote:
> Now that my image is working properly again and the fires have been put out,
> I wanted to introduce myself a bit better...
>
> My name is David Boeren. I first learned Smalltalk back in college many
> years ago, we used Smalltalk V in an object oriented programming class I
> took which was first-half Smalltalk, second-half C++. This would be about
> 1992 I think? In recent years I've mainly been using Java, with occasional
> Python dabblings. I remember installing Squeak once or twice over the
> years, but to be honest it felt a bit clunky, perhaps this was just an early
> primitive version or whatever.
>
> Recently, I've been getting the itch to try out some different languages. I
> was kind of looking at Scala or Clojure, one co-worker suggested Erlang, and
> so forth. But after doing a brief review I ended up coming back to
> Smalltalk which even after all these years still stands right up with the
> cutting edge I think. Sure, there are a few things that I think would be a
> little different if it were designed today like tuple support or whatever,
> but it feels like the right choice for something I'm going to use mainly for
> "fun" projects and the interactive environment is awesome.
>
>
> One thing I wanted to ask about is the status of getting Pharo running on
> iOS (or at least iPad). I found some old posts but nothing much within the
> last couple of years. I know there were app store policy issues in the past
> but I think that Apple has opened things up a bit since then, you can now
> get Pythonista in the app store, or Codea. Is there still an obstacle or is
> it just something that hasn't been gotten around to yet? I'd love to get it
> running on my iPad Mini and be able to transmit code back and forth between
> there and my laptop to work on it wherever I'm at.
>
>
> Second, I'm running into an oddity and I'm not sure what I'm doing wrong or
> whether this is a bug of some sort, this has to do with trying to replace
> unicode characters in a string which seems like it should be a
> straightforward operation. Here is my code:
>
> "Fetch the raw JSON data from dtdb.co"
> response := 'http://dtdb.co/api/cards/' asUrl retrieveContents asString.
>
> "Clean up the data a bit to make it a little more regular"
> response := response copyReplaceAll: 'null' with: '""'.
> response := response copyReplaceAll: '\u2022' with: ','.
> response := response copyReplaceAll: '\u009e' with: 'e'.
>
> Basically I'm just pulling some JSON data and then doing a few string
> replacements to make the data suit my needs. The first one works. The
> second one works. Since the third one ALSO uses a \uXXXX code I would
> expect it to work too, but it does not - the accented characters are still
> there.
>
> To get a bit more visibility into this, I copied the CopyReplaceAll code
> from SequenceableCollection into a scratch class method and adding some
> Transcript output:
>
> copyReplaceIn: aString All: oldSubCollection with: newCollection
> "Answer a copy of the receiver in which all occurrences of
> oldSubCollection have been replaced by newCollection "
>
> | startSearch currentIndex endIndex |
>
> Transcript show: 'start' ; cr.
> startSearch := 1.
> [(currentIndex := aString indexOfSubCollection: oldSubCollection
> startingAt: startSearch) > 0]
> whileTrue: [
> Transcript show: 'Found at index ' ; show: currentIndex ; cr.
> endIndex := currentIndex + oldSubCollection size - 1.
> aString := aString
> copyReplaceFrom: currentIndex
> to: endIndex
> with: newCollection.
> startSearch := currentIndex + newCollection size].
> Transcript show: 'done' ; cr.
> ^ aString
>
> A minimal test seemed to work:
> HelloWorld copyReplaceIn: 'R\u00e9my Lapointe' All: '\u00e9' with: 'e'.
>
> start
> Found at index 2
> done
>
> Testing this with the real data worked too:
> HelloWorld copyReplaceIn: ('http://dtdb.co/api/cards/' asUrl
> retrieveContents asString) All: '\u00e9' with: 'e'.
> start
> Found at index 22379
> Found at index 22500
> done
>
>
> However, when I went back to using the regular copyReplaceAll:With: method
> it does not work and I'm not sure why. When it executes this:
> aString indexOfSubCollection: oldSubCollection startingAt: startSearch
>
> The value comes back as 0 even though it's the same data from
> 'http://dtdb.co/api/cards/' asUrl retrieveContents asString (I added a "self
> halt" to be able to step into the method and view the variable values), and
> I'm not sure what the difference is. There shouldn't be a limit on the size
> of the collection, should there? The whole thing is around 116k which is
> big but not ridiculously so. It is however big enough that the debugger
> can't show the whole value, or at least I haven't found a way to do so.
>
>
> And last, is there a good video tutorial for the Pharo beginner on how to
> use the various browsers, debugger, tools, etc... that come with Pharo? I
> would like to start learning more about the best ways to use these in my
> development processes. I'm also having a lot of trouble finding the correct
> classes and message for what I want to do, searching online w/ Google often
> seem to turn up outdated information (or for a different smalltalk flavor)
> and it can take a while to figure out the correct way to do things. Is
> there a good central reference for the APIs somewhere? I know that you can
> search in the browser but I usually don't know the name to search for. It
> would be good to have a handy reference detailing how to do all the
> commonplace stuff.
>
> Thanks!
>
>
>
> --
> View this message in context: http://forum.world.st/New-Pharo-user-some-questions-tp4795325.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
Dec. 10, 2014
Re: [Pharo-users] Extending GTSpotter
by kilon alios
anything is doable. The barrier always is knowledge.
There is already a project to bring documentation and a specific kind of
documentation called Pillar which is what we use for updated PBE and Pharo
for the Enterprise books inside the GTInspector. Its a WIP.
On the side of GTSpotter you have a morphic wrapper called Brick that is
used to ease the design of the GUI.
But whether you use Glamour or Spec or Brick or whatever you use Morphic.
Only Bloc which suppose to be the new kid in the block to replace Morphic
is not Morphic but for now at least the heavy weight gorilla is Morphic. As
soon as you understand morphic you are unstopable.
Dynamic documentation is one of the things that Pharo really lacks if you
ask me, I am that annoying guy that complains about documentation all the
time. I think however that we get closer to this .
>From what I see you talk about class and instance comments. Of course with
Pillar at your side you can go way above that and provide functionality
that can rival pdf and html help files.
So yes its doable and yes you can take it very far but as always is about
having the will to do the hard work because in the end nothing is easy as
it looks or else someone else would have done it by now.
On Wed, Dec 10, 2014 at 8:49 PM, Edward Povazan <empovazan(a)gmail.com> wrote:
> Hello,
>
> I am having a blast with GTSpotter - itâs the missing link for me, just
> one step to ask a question from Pharo. Keeps the flow going!
>
> Being new to the innards of Pharo, Iâve decided to try something.
> I would love documentation in GTSpotter. For example, I am interested in
> how packages are organized in Pharo.
> Cmd+Enter: âPackage'
> I get a list of package type classes.
>
> Cmd+Sh+Right Arrow.
> Now I see all the classes in the Classes category ...
> PackageInfo, PackageOrganizer, GRPackage, RPackageOrganizer - all
> interesting candidates in my exploration.
>
> But now I need to browse into each, look at the docs, then bring back
> GTSpotter, navigate to the last context with History, and repeat. More than
> one step.
>
> So I am going to try:
> - when showing all items in classes and methods categories, add a little
> [d] tag to the end of the item text to indicate if there is documentation
> for that item (class/instance or method docs)
> - Cmd+Sh+Right will display the docs.
>
> Is this doable within the current framework?
> If so, I am going to chip away on this.
>
> Thanks,
> -Ed
>
>
>
Dec. 10, 2014
New Pharo user, some questions
by dboeren
Now that my image is working properly again and the fires have been put out,
I wanted to introduce myself a bit better...
My name is David Boeren. I first learned Smalltalk back in college many
years ago, we used Smalltalk V in an object oriented programming class I
took which was first-half Smalltalk, second-half C++. This would be about
1992 I think? In recent years I've mainly been using Java, with occasional
Python dabblings. I remember installing Squeak once or twice over the
years, but to be honest it felt a bit clunky, perhaps this was just an early
primitive version or whatever.
Recently, I've been getting the itch to try out some different languages. I
was kind of looking at Scala or Clojure, one co-worker suggested Erlang, and
so forth. But after doing a brief review I ended up coming back to
Smalltalk which even after all these years still stands right up with the
cutting edge I think. Sure, there are a few things that I think would be a
little different if it were designed today like tuple support or whatever,
but it feels like the right choice for something I'm going to use mainly for
"fun" projects and the interactive environment is awesome.
One thing I wanted to ask about is the status of getting Pharo running on
iOS (or at least iPad). I found some old posts but nothing much within the
last couple of years. I know there were app store policy issues in the past
but I think that Apple has opened things up a bit since then, you can now
get Pythonista in the app store, or Codea. Is there still an obstacle or is
it just something that hasn't been gotten around to yet? I'd love to get it
running on my iPad Mini and be able to transmit code back and forth between
there and my laptop to work on it wherever I'm at.
Second, I'm running into an oddity and I'm not sure what I'm doing wrong or
whether this is a bug of some sort, this has to do with trying to replace
unicode characters in a string which seems like it should be a
straightforward operation. Here is my code:
"Fetch the raw JSON data from dtdb.co"
response := 'http://dtdb.co/api/cards/' asUrl retrieveContents asString.
"Clean up the data a bit to make it a little more regular"
response := response copyReplaceAll: 'null' with: '""'.
response := response copyReplaceAll: '\u2022' with: ','.
response := response copyReplaceAll: '\u009e' with: 'e'.
Basically I'm just pulling some JSON data and then doing a few string
replacements to make the data suit my needs. The first one works. The
second one works. Since the third one ALSO uses a \uXXXX code I would
expect it to work too, but it does not - the accented characters are still
there.
To get a bit more visibility into this, I copied the CopyReplaceAll code
from SequenceableCollection into a scratch class method and adding some
Transcript output:
copyReplaceIn: aString All: oldSubCollection with: newCollection
"Answer a copy of the receiver in which all occurrences of
oldSubCollection have been replaced by newCollection "
| startSearch currentIndex endIndex |
Transcript show: 'start' ; cr.
startSearch := 1.
[(currentIndex := aString indexOfSubCollection: oldSubCollection
startingAt: startSearch) > 0]
whileTrue: [
Transcript show: 'Found at index ' ; show: currentIndex ; cr.
endIndex := currentIndex + oldSubCollection size - 1.
aString := aString
copyReplaceFrom: currentIndex
to: endIndex
with: newCollection.
startSearch := currentIndex + newCollection size].
Transcript show: 'done' ; cr.
^ aString
A minimal test seemed to work:
HelloWorld copyReplaceIn: 'R\u00e9my Lapointe' All: '\u00e9' with: 'e'.
start
Found at index 2
done
Testing this with the real data worked too:
HelloWorld copyReplaceIn: ('http://dtdb.co/api/cards/' asUrl
retrieveContents asString) All: '\u00e9' with: 'e'.
start
Found at index 22379
Found at index 22500
done
However, when I went back to using the regular copyReplaceAll:With: method
it does not work and I'm not sure why. When it executes this:
aString indexOfSubCollection: oldSubCollection startingAt: startSearch
The value comes back as 0 even though it's the same data from
'http://dtdb.co/api/cards/' asUrl retrieveContents asString (I added a "self
halt" to be able to step into the method and view the variable values), and
I'm not sure what the difference is. There shouldn't be a limit on the size
of the collection, should there? The whole thing is around 116k which is
big but not ridiculously so. It is however big enough that the debugger
can't show the whole value, or at least I haven't found a way to do so.
And last, is there a good video tutorial for the Pharo beginner on how to
use the various browsers, debugger, tools, etc... that come with Pharo? I
would like to start learning more about the best ways to use these in my
development processes. I'm also having a lot of trouble finding the correct
classes and message for what I want to do, searching online w/ Google often
seem to turn up outdated information (or for a different smalltalk flavor)
and it can take a while to figure out the correct way to do things. Is
there a good central reference for the APIs somewhere? I know that you can
search in the browser but I usually don't know the name to search for. It
would be good to have a handy reference detailing how to do all the
commonplace stuff.
Thanks!
--
View this message in context: http://forum.world.st/New-Pharo-user-some-questions-tp4795325.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Dec. 10, 2014
What do you suppose about this ?
by Hans Schueren
What do you suppose about this ?
from Hans the Byte Surfer.
ViewManager subclass: #GraphicsDemo
instanceVariableNames:
'pen graphs selectedGraph pane bitmap '
classVariableNames:
'Count '
poolDictionaries:
'ColorConstants ' !
!GraphicsDemo class methods !
initialize
"Private - Set the color count to 0."
Count := 0.! !
!GraphicsDemo methods !
animationMenu
"Private - Answer the animation menu."
^(Menu
labels: 'Big red\Little blue\Spider\Stop\Clear' withCrs
lines: #()
selectors: #(bigRed littleBlue spider deactivateAnimation
clearAnimation))
title: '&Animation';
owner: self;
yourself!
bigRed
"Private - Create a red animated mandala."
| mandala |
mandala := AnimatedObject mandala: 11 diameter: 72 color: ClrRed.
pane addObject: mandala.
mandala display!
cleanUp
"Private - Clean up GraphicsDemo before closing."
self clearAnimation.
bitmap notNil
ifTrue: [bitmap release].!
clearAnimation
"Private - Clear the animation."
| objects |
objects := pane contents.
pane clear.
objects do: [: each | each frames do: [: f | f release]]!
close: aPane
"Private - Release the bitmaps of the animated objects."
Smalltalk isRunTime
ifTrue: [
(MessageBox confirm: 'Are you sure you want to exit?')
ifTrue: [
self cleanUp.
self close.
^Smalltalk exit]
ifFalse: [
^self]]
ifFalse: [
self cleanUp.
Transcript notNil ifTrue:[
Transcript enableDemo].
^super close].!
copyMetaFile
"Copy a metafile to the clipboard."
| storedPicture |
storedPicture := pen segments at: (graphs at: #mandala).
storedPicture isNil ifTrue: [^self].
storedPicture pen width: pen width;
height: pen height.
Clipboard setMetaFile: storedPicture!
deactivateAnimation
"Private - Stop the animation."
pane stopAll!
display: aPane
"Private - Display aPane contents."
selectedGraph isNil
ifTrue: [pen erase]
ifFalse: [
selectedGraph = #displayBitmap
ifTrue: [^self displayBitmap].
graphs at: selectedGraph ifAbsent: [^self].
pen erase.
pen drawSegment: (graphs at: selectedGraph)]!
displayBitmap
"Private - Paste the bitmap."
bitmap notNil
ifTrue:[
pen copyBitmap: bitmap
from: bitmap boundingBox
to: (0 @ 0 extent: pen extent)]!
drag: aPane
"Private - Track the mouse."
| animatedObject |
animatedObject := aPane childAt: aPane mouseLocation.
animatedObject notNil
ifTrue: [animatedObject drag: aPane mouseLocation].
aPane when: #button1Move perform: nil!
dragon
"Private - Draw a dragon pattern where anInteger
is the recursion factor."
self drawBlockNow: [
pen
home;
north;
dragon: 11]
for: #dragon!
drawBlock: aBlock for: symbol
"Private - Draw the selected graphics in a segment
and make a backup."
| intState wasActive |
wasActive := pane stop.
pen erase.
selectedGraph := symbol.
(graphs includesKey: symbol)
ifFalse: [
graphs at: symbol put: (pen retainPicture: aBlock)].
self display: nil.
pane makeBackup.
wasActive ifTrue: [pane go]!
drawBlockNow: aBlock for: symbol
"Private - Draw the selected graphics and make a
backup of the receiver."
| intState wasActive |
wasActive := pane stop.
pen erase.
selectedGraph := symbol.
(graphs includesKey: symbol)
ifTrue: [self display: nil]
ifFalse: [
graphs at: symbol put: (pen drawRetainPicture: aBlock)].
pane makeBackup.
wasActive ifTrue: [pane go]!
drawMandalas
"Private - Draw 8 mandalas."
(Commander pen: 8 forDC: pen handle medium: pane)
place: (self mainView rectangle extent) // 2;
fanOut;
up;
go: 90;
down;
mandala: 12 diameter: 170 initDir: 270!
drawSpirals
"Private - Draw 4 spirals."
| commander |
commander := (Commander pen: 4 forDC: pen handle medium: pane).
commander
place: (self mainView rectangle extent) // 2;
fanOut;
up;
go: 90;
down.
1 to: 180 do: [: i |
commander
go: i;
turn: 122]!
drawWalkLine
"Private - Draw rotating lines."
| incrX incrY numberOfLines boundX |
numberOfLines := 60.
incrX := pen width / numberOfLines.
incrY := pen height / numberOfLines.
boundX := (incrX * (numberOfLines)).
1 to: numberOfLines + 1 do: [: i |
pen
foreColor: (GraphicsTool paletteIndex: (
(Count := Count + 1) \\ 7 + 1));
place: (i - 1 * incrX) rounded @ 0;
goto: (boundX - (i * incrX) @ (i * incrY)) rounded]!
drawWith: graphPane
"Private - Assign the receiver's pen."
pen := graphPane pen!
graphicsMenu: aPane
"Private - Set the menu for the graph pane."
aPane setMenu: (
(Menu
labels: '&Walk Line\&Mandala\M&ulti
Mandala\&Dragon\Multi &Spiral\&Paste' withCrs
lines: #()
selectors: #(walkLine mandala multiMandala dragon
multiSpiral paste))
title: '&Graphics';
owner: self;
yourself)!
initWindowSize
"Private - Answer default initial window extent."
^Display extent * 7 // 8!
littleBlue
"Private - Create a blue animated mandala."
| mandala |
mandala := AnimatedObject mandala: 9 diameter: 48 color: ClrBlue.
pane addObject: mandala.
mandala display!
mandala
"Private - Draw a mandala."
pen home.
self drawBlockNow: [
pen mandala: 20 diameter: pen height * 7 // 8]
for: #mandala!
mouseDown: aPane
"Private - Process a mouse down event."
| aPoint animatedObject |
aPoint := aPane mouseLocation.
animatedObject := aPane childAt: aPoint.
animatedObject notNil ifTrue: [
^aPane when: #button1Move perform: #drag:]!
multiMandala
"Private - Draw 8 mandalas."
self drawBlockNow: [self drawMandalas]
for: #multiMandala!
multiSpiral
"Private - Draw 4 spirals."
self drawBlockNow: [self drawSpirals]
for: #multiSpiral!
open
"Open the graphics demo window."
graphs := Dictionary new.
self label: 'Graphics Demo';
foreColor: ClrBlack;
backColor: ClrWhite;
when: #close perform: #close:;
owner: self.
self addSubpane: (pane := AnimationPane new
owner: self;
when: #getContents perform: #drawWith:;
when: #display perform: #display:;
when: #button1Down perform: #mouseDown:;
when: #getMenu perform: #graphicsMenu:).
self openWindow.
self menuWindow addMenu: self animationMenu.!
paste
"Private - Paste a bitmap from the clipboard to window."
selectedGraph := #displayBitmap.
bitmap notNil ifTrue: [bitmap release].
(bitmap := Clipboard getBitmap) isNil ifTrue: [^self].
self displayBitmap.
pane makeBackup!
pasteMetaFile
"Paste a metafile from the clipboard."
| storedPicture |
storedPicture := Clipboard getMetaFile.
storedPicture isNil ifTrue: [^self].
pen erase.
storedPicture play: pen!
setScale
"Private - Set the scale for displaying selected graph demo."
| scale |
scale := (pen width * 2 / pen width) @ (pen height * 2 /
pen height).
(pen setScale: scale) = 1
ifFalse: [^self error: 'setScale error'].
self perform: selectedGraph!
spider
"Private - Create a spider chaser."
| spider |
spider := AnimatedObject spider: 100.
pane addObject: spider.
spider endBlock: [: s | Menu message: 'Gotcha!! !!'].
spider display.
spider animate!
walkLine
"Private - Draw rotating lines."
self drawBlock: [self drawWalkLine]
for: #walkLine! !
Dec. 10, 2014
Extending GTSpotter
by Edward Povazan
Hello,
I am having a blast with GTSpotter - itâs the missing link for me, just one step to ask a question from Pharo. Keeps the flow going!
Being new to the innards of Pharo, Iâve decided to try something.
I would love documentation in GTSpotter. For example, I am interested in how packages are organized in Pharo.
Cmd+Enter: âPackage'
I get a list of package type classes.
Cmd+Sh+Right Arrow.
Now I see all the classes in the Classes category ...
PackageInfo, PackageOrganizer, GRPackage, RPackageOrganizer - all interesting candidates in my exploration.
But now I need to browse into each, look at the docs, then bring back GTSpotter, navigate to the last context with History, and repeat. More than one step.
So I am going to try:
- when showing all items in classes and methods categories, add a little [d] tag to the end of the item text to indicate if there is documentation for that item (class/instance or method docs)
- Cmd+Sh+Right will display the docs.
Is this doable within the current framework?
If so, I am going to chip away on this.
Thanks,
-Ed
Dec. 10, 2014