How to create a new source file in Pharo? - smalltalk

I downloaded the Pharo launcher and stable appimage for version 9.0 in Windows 10. Now I want to try a hello world program, but I can't see a "create new file" option.
How do I create a new source file?

Update: adding examples and adding information
You should understand the original philosophy of the Smalltalk.
The whole OS was supposed to be written in Smalltalk and the GUI was to call the Smalltalk libraries in the OS.
The whole IDE was meant to be an enclosed world. It did not evolve that way so now Smalltalk has to communicate with the outside world somehow, but it kept its ways when creating new code.
For your hello world application you need to, either use Transcript (Transcript show: 'Hello World') for short, testing code or as Leandro has written create a 'HelloWorld' package.
An example of such package:
Object subclass: #Greeting
instanceVariableNames: ''
classVariableNames: ''
package: 'HelloWorld'
You can find nice tutorials already created so please take advantage of those. I'll direct you to one, which contains answer to your question:
Pharo quick start by Richard Kenneth

Related

I have a problem with Kotlin. Running external programs

How to run external programs in pure Kotlin?
From a program written in Kotlin for Windows, I want to run external programs. I want to do it I want to do it in pure Kotlin (not Java). Please provide sample code.
For example: how to start and open Notepad with .txt file, MyProgram.exe. (in Windows it's the WinExec() function) What to read about it, maybe a few links. :)
I'm a beginner. I've read the kotlin documentation and couldn't find anything.

Standard Input in Smalltalk (Pharo) on Windows

I'm currently trying to learn the "most elegant and powerful" programming language since I'll need to be using it in about two months. However, I've been searching for an entire half-hour, and I have one simple request.
How do you read standard input with Pharo 7.0 Smalltalk on Windows? The solution I found here only works on Linux via using /dev/stdin as a file.
Getting to standard input from a GUI application on Windows is not trivial (see https://social.msdn.microsoft.com/Forums/vstudio/en-US/799cc2b6-309e-4758-8c3b-7c602bbfb736/in-a-gui-program-where-is-stdout?forum=vcgeneral) and few GUI applications support it.
Why do you want to do this? Is it so you can transfer what you've learned from C/C++/C#/Java/Python and other such console-based environments? If so, I suggest you change your approach. Instead of trying to transfer your C tutorials to Smalltalk, I suggest that you learn Pharo using https://mooc.pharo.org. If you want to look at user input in a GUI context, take a look at the UIManager.
On the other hand, if you must write a console-based application, see CommandLineUIManager.

How Exactly Do You Build A GUI Application in Squeak

All the tools that i searched are 2005 or 2006 and so i dont even dare to try those. I understand that morphic is ok , but i am looking for something like Morphic Designer.
http://www.youtube.com/watch?v=rmlgU5p4g3o
If you look at this link you will feel all excited and will be tempted to try it out. But unfortunately in todays squeak you cannot even load those mentioned packages. Its a pity. Any help is appreciated.
AFAIK the Morphic Designer is currently in a better state than the GsoC project to build a UI designer for spec. It seems to be usable for more complex interfaces, atm. The main issue in making it work with Pharo is probably the use of the signals library. That is somewhat equivalent to Announcements, but it follows QT style. And of course there are differences in which widgets are being used.
The number of actual users seems to be too low. I think HPI should open up their CI for these kinds of projects.
In a discussion on the Pharo Users mailing list some issues and solutions for making Morphic Designer work on Pharo 2.0 and 3.0 are described.
Have you tried loading the Morphic Designer? If so, how?
https://www.hpi.uni-potsdam.de/hirschfeld/trac/SqueakCommunityProjects/wiki/designer
The Designer should load in Squeak 4.3 and I see no reason that it
won't load in 4.4.
If you find issues loading the Designer, pleas let the developer know!
I happen to know that Marcel really cares that the designer is usable.
The development version of the Morphic Designer works fine in Squeak 4.4 as I use it frequently for my research:
(Installer mc http: 'http://www.hpi.uni-potsdam.de/hirschfeld/squeaksource/')
project: 'MetacelloRepository';
install: 'ConfigurationOfDesigner'.
(Smalltalk at: #ConfigurationOfDesigner) loadDevelopment.
UiDesigner open.
As you may have noticed, this will bootstrap Metacello and also load Signals, Animations and Widgets into your image. I am using the latest build of the CogVM.
I started to port it (Widgets & Designer) to Pharo 2.0. However, Pharo 2.0 is not fully supported yet.
Finally i could open the UiDesigner.
Im not sure if i am all0wed to use this in my personal projects. as #aka.nice ponted out this dont belong to the squeak community, rather it belongs to Hasso Plattner Institut. Correct me if i am wrong. Anyway i belive since i was able to get it, i can use it too. So ppl looking for Morphic Designer/ UiDesigner/ GUI in Smalltalk/Squeak can get it this way. WARNING - this is - as of 23/12/2013. This may change without prior notice and that u will have to look for other alternatives to get this.
Also id like to see this in pharo too. I had asked this question to the pahro community some months before. At that time i managed with glamour.
(Installer monticello http:'http://seaside.gemtalksystems.com/ss')
project: 'metacello';
install: 'ConfigurationOfMetacello'.
((Smalltalk at: #ConfigurationOfMetacello) project
latestVersion) load.
(Installer mc http: 'http://www.hpi.uni-potsdam.de/hirschfeld/squeaksource/')
project: 'MetacelloRepository';
install: 'ConfigurationOfWidgets'.
(Smalltalk at: #ConfigurationOfWidgets) load.
(Installer mc http: 'http://www.hpi.uni-potsdam.de/hirschfeld/squeaksource/')
project: 'MetacelloRepository';
install: 'ConfigurationOfDesigner'.
(Smalltalk at: #ConfigurationOfDesigner) load..
UiDesigner open
Spec is an easy-to-use framework for building GUIs. It's not as easy as a GUI builder though. If you want to learn more, there are plenty of examples in Pharo itself a small tutorial at
https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/lastSuccessfulBuild/artifact/Spec/Spec.pier.html
http://www.bahmanm.com/blogs/spec-part-1-basics

How to do load/library

In the past, using REBOL/Command, this worked fine. Now, I'm trying to load/library a .dll that I compiled and there is no /library refinement for load any longer. What is the equivalent in Rebol 3? Do I have to make an 'extension and import it?
Yes, Rebol 3 does not currently contain a Rebol 2-like DLL interface, which was limited and did not offer many useful options to wrap libraries, and e.g. callbacks were very limited too. Rebol 3 solved the situation by introducing an extension mechanism, which involves a little bit of a C code.
There was also some initiative to bring in improved Rebol 2-like DLL interface in form of a Rebol 3 extension, but the project did not work out yet, although after the ReCode conference, someone was claiming, it will come.
What you could also use is Red/System: it is a Rebol-like language, but very close to C level, so rather easy to wrap things around. Kaj De Vos created some examples, which show how to write an Rebol 3 extension as Red/System DLL.
Since this was answered, some versions of Rebol3 eg. Atronix, have the foreign function library compiled in so that you can
make library! %some.dll
See https://github.com/zsx/r3/blob/atronix/make/tests/ms-drives.r for an example on windows, and https://github.com/zsx/c2r3/blob/master/demos/gtk-demos/gtk-demo.reb for a comprehensive linux example.

Thunderbird scripting

I need to process a number of messages in my Thunderbird.app (Mac OS X Snow Leopard, Intel Core 2 Duo), delete a few based on some criteria, export some others, move a small part of them to a special folder and create a filing hierarchy to go with it all - programmatically.
With Outlook I used to enjoy VBScript + the COM object model: it would do all of the above simply and intuitively.
What can I use to achieve the same with Thunderbird?
If multiple options are available, here are my current preferences in terms of languages (although I can adapt to most things): Python, C++, AppleScript, PHP, Perl, Bash, ...
If I need to move to a Windows box to use .NET and the like, I can (yet I'd imaging the most popular bindings come from the open-source world?!) If there was a command-line tool that did what I need, I'd use that! (thunderbird.sh show messages; thunderbird.sh create folder X as child of folder Y;)
You can develop Thunderbird extensions in a similar way to Firefox extensions in XUL and Javascript.
Try this tutorial.
This tutorial will introduce you to the components of a Thunderbird extension and will show you how to build your own.
You could also look at the tbscript plugin, although it does have external dependencies - it uses Python.
The tutorial linked to in the most popular answer as of today still works, but is outdated.
For current versions of Thunderbird, documentation is at https://developer.thunderbird.net. This has an add-on page that comes with a tutorial for developing a "Hello World" MailExtension.
The MailExtension API is new for Thunderbird 68 (although some parts were published for earlier versions) and allows one to write JavaScript to e.g. handle messages.
If you need a general purpose GUI scripting solution, try Autohotkey, it's very calable.