PortablE
PortablE E language
63 posts | Last Activity on 30-10-2011 17:34 by SamuraiCrow
SamuraiCrow 30-10-2011 17:34, 12 years ago
Re: bitset inventory example
Ok! Here is the long awaited inventory example!
Call this file inventory.e
[code]
OPT MODULE
CLASS item
itemnum:INT
pad1:INT
description:ARRAY OF CHAR
ENDCLASS
DEF nextitem:INT,itemlist[32]:ARRAY OF PTR TO item
PROC makeitem(describe:ARRAY OF CHAR) NEW OF item
self.itemnum:=nextitem
itemlist[nextitem]:=self
++nextitem
IF nextitem>31 THEN Raise("ARG")
self.description:=describe
ENDPROC
PROC getmask() OF item RETURNS mask:LONG IS 1 SHL self.itemnum
PROC getdescription() OF item IS self.description
CLASS inventory
mask:LONG
ENDCLASS
PROC makeinventory() NEW OF inventory
self.mask:=0
ENDPROC
PROC additem(myitem:PTR TO item) OF inventory
self.mask:=self.mask OR myitem.getmask()
ENDPROC
PROC removeitem(youritem:PTR TO item) OF inventory
self.mask:=self.mask AND NOT youritem.getmask()
ENDPROC
PROC hasitem(myitem:PTR TO item) OF inventory RETURNS ret:BOOL
ret:= (self.mask AND myitem.getmask()=myitem.getmask())
ENDPROC
PROC hasany(items:PTR TO inventory) OF inventory RETURNS ret:BOOL
ret:=(self.mask AND items.mask <> 0)
ENDPROC
PROC hasall(items:PTR TO inventory) OF inventory RETURNS ret:BOOL
ret:=(self.mask AND items.mask = items.mask)
ENDPROC
PROC getitem(source:PTR TO inventory, theitem:PTR TO item) OF inventory RETURNS ret:BOOL
ret:=FALSE
IF source.hasitem(theitem)
source.removeitem(theitem)
self.additem(theitem)
ret:=TRUE
ENDIF
ENDPROC
PROC giveitem(destination:PTR TO inventory, theitem:PTR TO item) OF inventory RETURNS ret:BOOL
ret:=destination.getitem(self,theitem)
ENDPROC
PROC useall(items:PTR TO inventory) OF inventory RETURNS ret:BOOL
ret:=FALSE
IF self.hasall(items)
self.mask:=self.mask AND NOT items.mask
ret:=TRUE
ENDIF
ENDPROC
PROC list() OF inventory
DEF count:INT,current:PTR TO item
FOR count:=0 TO nextitem-1
current:=itemlist[count]
IF self.hasitem(current)
Print('\s\n',current.getdescription())
ENDIF
ENDFOR
ENDPROC
[/code]
And here's the code to test it out:
[code]
MODULE '*inventory'
DEF lamp:PTR TO item, torch:PTR TO item, bag:PTR TO item,
room:PTR TO inventory, mystuff:PTR TO inventory, lights:PTR TO inventory,
allstuff:PTR TO inventory
PROC getit(what:PTR TO item)
IF mystuff.getitem(room,what)
Print('You\'ve picked up \s.\n', what.getdescription())
ELSE
Print('You aleady have \s.\n', what.getdescription())
ENDIF
ENDPROC
PROC main()
DEF in[4]:STRING
NEW lamp.makeitem('a lamp')
NEW torch.makeitem('a torch')
NEW bag.makeitem('a bag')
NEW room.makeinventory()
NEW mystuff.makeinventory()
NEW lights.makeinventory()
NEW allstuff.makeinventory()
room.additem(lamp)
room.additem(torch)
room.additem(bag)
lights.additem(lamp)
lights.additem(torch)
allstuff.additem(lamp)
allstuff.additem(torch)
allstuff.additem(bag)
REPEAT
IF mystuff.hasany(lights)
Print('You are in a room with no doors and no windows.\n')
Print('You see:\n')
room.list()
ELSE
Print('It\'s dark. You are likely to be eaten by a grue.\n')
ENDIF
Print('\nWhat do you grab?\n')
PrintFlush()
ReadStr(stdin,in)
SELECT in[0]
CASE "l"; getit(lamp)
CASE "t"; getit(torch)
CASE "b"; getit(bag)
DEFAULT; Print('I don\'t see it here.\n')
ENDSELECT
UNTIL mystuff.hasall(allstuff)
Print('You have everything! You win!\n')
PrintFlush()
FINALLY
PrintException()
ENDPROC
[/code]
I'll break this down for you in the next week or so.Responded in bitset inventory example
SamuraiCrow 26-10-2011 11:56, 13 years ago
Re: Developer environment
Thinking back, I think that ChrisH already fixed PortablE for AROS so that the errors I ran into won't be there in the final release 6 version. He just hasn't come out with the final release yet. Recently I remember him cleaning up bugs on AROS and MorphOS both. I hope he finds time to finish up the release so I can continue the tutorial.
@Magorium
I don't know if the server services from VirtualBox would be more viable. There is an option to do something like that in the Icaros installer though, IIRC.Responded in Developer environment
magorium 22-10-2011 11:25, 13 years ago
Re: Developer environment
@SamuraiCrow:
Ah ic. I took develop environment a little too literaly ;) Sorry 'bout that.
Yeah, i am familiar with the problem you're facing. Missing VB-GA sux.
I doubt that you didn't already think of this yourself (or perhaps you are unable to apply in practice) but whenever i need to transfer files from one box to another i use the VBox network. If i have to transfer out of the box'es i use an USB stick or serial port (installed virtual serial port on host-OS). This is the reason i was thinking about something like freenas in a extra Box in order to transfer back and forth between guest and host in a more consisent way
Alas, it really doesn't make things smoother :(
OT: Since you have more aros experience, do you think it would be viable to interact with the VM's server services from aros ?
@cavemann:
Thank you for sharing that link :). I didn't know about that.
regards,Responded in Developer environment
SamuraiCrow 21-10-2011 13:08, 13 years ago
Re: bitset inventory example
[url]http://cshandley.co.uk/amigae/[/url] is the E manual as a webpage.
[url]http://cshandley.co.uk/portable/[/url] is the homepage of PortablE including download links.
[url]http://cshandley.co.uk/portable/PortablE.html[/url] is the PortablE manual listing all of the differences between PortablE and AmigaE.
[url]http://cshandley.co.uk/portable/StandardFunctionality.html[/url] is the manual for the PortablE classes.Responded in bitset inventory example
SamuraiCrow 21-10-2011 12:41, 13 years ago
Re: Developer environment
I had difficulty installing Icaros in such a way that I could transfer files to and from the host MacOSX 10.6.x environment. In the past I had used hosted AROS on Linux in VirtualBox so that I could use the VirtualBox Guest Additions.
Editors have very little to do with what problems I'm having. I used TextEdit under MacOSX for the IRC tutorial series so it doesn't have to be anything advanced.Responded in Developer environment
amigamia 20-10-2011 08:57, 13 years ago
Re: bitset inventory example
Would you mind to post the link to online material such as Books or Manuals we may need on E and PortablE? :)Responded in bitset inventory example
magorium 19-10-2011 20:58, 13 years ago
Re: Developer environment
Thank you for moving :-)
Sorry I made a wrong assumption about the OS SamauraiCrow ... Ofcourse you are correct -> if you where using windows you could use the windows version :mestupid:
So that would probably also mean that i wrongly assume portableE is written in E ?
I intentionaly mentioned editors that are available for AROS, as i thought that _is_ the issue. Or did i misunderstand the intentional problem ?
btw Annotate works for me under icaros desktop.
PS sorry to see on that you mentioned having problems with compiling due to header errors.
regardsResponded in Developer environment
cavemann 19-10-2011 20:45, 13 years ago
Re: Developer environment
I don't think the most recent version (2.7.8) has been ported to AROS yet.
[url]http://hem.bredband.net/deniil/[/url]Responded in Developer environment
amigamia 19-10-2011 20:05, 13 years ago
Re: Developer environment
I think it already is, isn't it?
AROS ARCHIVES:
[url]http://archives.aros-exec.org/index.php?function=showfile&file=utility/text/edit/annotate.i386-aros.zip[/url]
From OnyxSoft:
[url]http://www.onyxsoft.se/annotate.html[/url]
It shows 2.7 on both..Responded in Developer environment
SamuraiCrow 19-10-2011 16:10, 13 years ago
Re: Developer environment
Yes, Annotate does have AmigaE syntax highlighting. I've used it under OS 3. I hope that the latest version gets backported from OS 4 to OS 3 and AROS.Responded in Developer environment
amigamia 19-10-2011 14:58, 13 years ago
Re: Developer environment
I thought Annotate had E language Syntax Highlighting and it is now available for AROS. I guess that could be a good editor under windows?Responded in Developer environment
SamuraiCrow 19-10-2011 11:22, 13 years ago
Re: Developer environment
I use VirtualBox for Mac. I haven't used Windows for a good many years except at friends' and relatives' houses. If I had Windows, I could just use the Windows version of PortablE.
I normally use hosted AROS from within a Linux virtual machine. But my Linux VM is getting hard to manage and I can't seem to get either Mac or Linux versions of X11 to enable the Backingstore option.Responded in Developer environment
magorium 19-10-2011 11:16, 13 years ago
Re: Developer environment
Hi SamuraiCrow,
Sorry for (sort of) hijacking this thread, please replace or delete if wanted.
[moved to new thread --SamuraiCrow]
1) could Frexxed ([url]http://daniel.haxx.se/frexxed/[/url]) be a viable option ?
2) if you are using VB then i assume u use windblows ? If so, perhaps programmer's notepad ([url]www.pnotepad.org/[/url]) is an option ? I realize then there is a problem with executing code that uses gui elements as E does not have support for them under windblows.
It is an interresting topic, also for me, because it's a bit problematic: developing in other languages then c in combination with AROS -> the lack of a real configurable editor that is aimed for developers. I could not find anything else myself.
atm i run two VB's one with windblows another with aros. This is because i have to test the software on two platforms and the editor is in windows.
I use VB's internal network to communicate between the two, but i'm thinking of changing it in adding a third box with something like freenas.
I believe aros does not has a remote-shell ? That would be a better option.
Please share the experience (others are welcome) if you can spare the time.
regards
red: forgot to mention annotate ([url]http://www.onyxsoft.se/annotate.html[/url])Responded in Developer environment
SamuraiCrow 18-10-2011 20:57, 13 years ago
Re: bitset inventory example
I apologize for not actually starting the example code, but I'm trying to get a decent development environment going for AROS and PortablE.
I'll probably just install Icaros on a VirtualBox VM and forget about being able to transfer files in and out except via the internet.Responded in bitset inventory example
SamuraiCrow 17-10-2011 20:30, 13 years ago
Re: bitset inventory example
Ok class, welcome to the PortablE programming course.
For these lessons, we're going to be implementing a bitset class. This will allow the presence or absence of up to 32 items to be mapped into only 4 bytes of memory using logic operations.
In order to make a class to hold items, the first thing we have to do is make a definition of what kind of items we can put into storage in the bitset. What we need for this to take place is to make a unique identification number for each item starting at zero. The next thing we want is a name so we can identify each item going into the list. Thirdly we'll need a way to list the contents of the set.
If there are are any questions, I'll answer them as we go. We'll be making this using a purely object-oriented approach. Anyone who has been in the IRC channel discussions will have to note that these lessons are in PortablE rather than AmigaE so they will look a little different.Responded in bitset inventory example
SamuraiCrow 17-10-2011 20:07, 13 years ago
Re: PortablE for MAC OS X
Thanks.Responded in PortablE for MAC OS X
amigamia 17-10-2011 14:39, 13 years ago
Re: PortablE for MAC OS X
Alright! Feel free to create a new thread anytime you like. I have made you the forum Moderator for PortablE. You can upload attachments if you need to. Let me know what else you need. You can make them stickies as well.Responded in PortablE for MAC OS X
SamuraiCrow 17-10-2011 11:44, 13 years ago
Re: PortablE for MAC OS X
I'd prefer to do it as forum threads. :)Responded in PortablE for MAC OS X
amigamia 13-10-2011 15:55, 13 years ago
Re: PortablE for MAC OS X
You know that is a very good idea. I'd love to host some E and PortablE tutorials here on AROSWORLD. We can do it in two forms: 1) As an article page 2) As forum threads. Let me know which was you prefer?Responded in PortablE for MAC OS X
SamuraiCrow 13-10-2011 12:29, 13 years ago
Re: PortablE for MAC OS X
Well, I am holding E classes on Sunday afternoons at 3 PM CDT (8 GMT) on the #AmigaE channel on irc.Freenode.net but it's turning more into a discussion on how to implement a game engine in E.
We still have the code from the first two months of classes but not the logfiles. I had mainly offered to teach Cammy about E but she invited others to learn as well. You're welcome to show up also but since some people couldn't make it every week, it's mainly there for me and Cammy.
If you'd like, I could start over here in a thread about learning PortablE.Responded in PortablE for MAC OS X
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot start a new discussion thread in this forum.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
Moderator: Administrator