Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
143 user(s) are online (117 user(s) are browsing Forums)

Members: 1
Guests: 142

LiveForIt, more...

Support us!

Headlines

 
  Register To Post  

(1) 2 3 »
Learning HollyWood (~Tutorial) Vol. 1
Quite a regular
Quite a regular


See User information
The learner's guide strangely refers to printing on the screen as "Text Rendering Functions" (which is cryptic, sounds like you are doing something 3D graphics wise) and lists it at 15.2 in the instruction "book". Thing is, people want to PRINT something on the screen immediately! I think it's backwards to bury it near the END of the guide.

Out of the gate, they want a window and to be able to place text, no matter how much else needs to be known, they want the ability to DO something that feels substantial. That is what a computer is for, you putting your message in view.

Another problem is the index.

There should be, although done quite differently, a listing for "REM" short for Remark and also Read and Data statements. I can see that the language doesn't use them, but they extend back to the 1960's in usage, and people migrating are looking for equivalents if actual duplication is impossible.

The index should list READ, DATA and REMARK and point to what they are in HollyWood terminology and mention it in the text more obviously.


I'm trying to retrieve the full time and display it in the following 2 lines as output.

Wednesday January 21, 2009
8:01:36 a.m.

They second line is aligned on the right.

**** start
LABEL (TIMESTAMP)
CURRDATE$=GetWeekday().." "..MOY$[GetDateNum(#DATEMONTH)].." "..STRSTR(GetDateNum(#DATEDAY))..","..STRSTR(GetDateNum(#DATEYEAR))
CURRTIME$=GetTime(TRUE)
TEMP=Val(LeftStr(CURRTIME$,2))
If TEMP>11
If TEMP>12
CURRTIME$=StrStr(TEMP-12)..UnRightStr(CURRTIME$,2)
Endif
CURRTIME$=CURRTIME$.." p.m."
Else
If TEMP=0
CURRTIME$="12"..UnRightStr(CURRTIME$,2).." a.m."
Else
If TEMP<10
CURRTIME$=UnRightStr(CURRTIME$,1).." a.m."
Endif
EndIf
Endif
RETURN
**** end

That's a lot of code to do it, I was wondering if I made some kind of mistake? Also, I had to make an array so that I could print the name of the month.


Another question I have is about
TextOut (0,0,"Hello")

I may have missed how to, but I wanted to say do the above, then read keyboard input, then I want to continue Textout from where I left off, and I can't see if there's a way to do it. I tried

TextOut (,,RESTOFLINE$)

RESTOFLINE$ being something the user types in. This doesn't work. I'm pretty sure in AMOS that that was how I continued on, to extend the text writing. I went with what I knew.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Quite a regular
Quite a regular


See User information
The

InKeyStr()

command is a real let down!

In AMOS Pro, there is an Inkey$ command that retrieves only one character from the keyboard, and then you can react to the character as you please. It doesn't appear on the screen, you decide if it's displayed or not, even.

In Hollywood, the letter appears on the screen, so I can't filter out letters from appearing which cannot be selected. Also, a RETURN must be entered, unlike in AMOS.

There is
IsKeyDown()

But then I'd have to

Repeat
Until IsKeyDown("Q")=TRUE or IsKeyDown("q")=TRUE or IsKeyDown("N")=TRUE or IsKeyDown("n")=TRUE or IsKeyDown("S")=TRUE or IsKeyDown("s")=TRUE or IsKeyDown("E")=TRUE or IsKeyDown("e")=TRUE or IsKeyDown("W")=TRUE or IsKeyDown("w")=TRUE

For quit or north or south or east or west, and I see that it wouldn't work anyway, as the second comparison would get a NEW key depressed variable anyway. Not possible to do in HollyWood, I can see.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
@Atheist

I see that you have noticed that Hollywood isn't the same as AMOS. Now quit complaining about the differences and calling everything "cryptic" and a "let down." You are going to have to learn the Hollywood way of doing things. That will take a little time.

Text rendering functions are just that, they render strings of text to the screen at a specified location. It's designed to be a graphics/multimedia system, not a DOS console. Moreover, I just looked in the Hollywood guide under text rendering functions, and there are Print and NPrint functions! Why are you using TextOut when what you want is the console like behaviour of Print?

To spell it out:
Print - prints a line of text
NPrint - prints a line of text and then moves down to the next line
Locate - is used to change the position of the cursor.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
@Atheist

Quote:

Atheist wrote:
The

InKeyStr()

command is a real let down!

In AMOS Pro, there is an Inkey$ command that retrieves only one character from the keyboard, and then you can react to the character as you please. It doesn't appear on the screen, you decide if it's displayed or not, even.

In Hollywood, the letter appears on the screen, so I can't filter out letters from appearing which cannot be selected. Also, a RETURN must be entered, unlike in AMOS.

There is
IsKeyDown()

But then I'd have to

Repeat
Until IsKeyDown("Q")=TRUE or IsKeyDown("q")=TRUE or IsKeyDown("N")=TRUE or IsKeyDown("n")=TRUE or IsKeyDown("S")=TRUE or IsKeyDown("s")=TRUE or IsKeyDown("E")=TRUE or IsKeyDown("e")=TRUE or IsKeyDown("W")=TRUE or IsKeyDown("w")=TRUE

For quit or north or south or east or west, and I see that it wouldn't work anyway, as the second comparison would get a NEW key depressed variable anyway. Not possible to do in HollyWood, I can see.


The right way to do this would be to install an event handler for key up (i.e., wait for the user to release the key) with InstallEventHandler and have a function that reads the events. Then the main function just sits in a loop with a WaitEvent call.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Just popping in
Just popping in


See User information
Instead of REM Hollywood uses ;
Here is a complete and very simple example:

Function PrintMyKey(k)
   ; 
This function is called everytime the user release a key
   NPrint
(k)
EndFunction

Below we are telling Hollywood to call the function
PrintMyKey everytime the user release a keyboard key
InstallEventHandler
({OnKeyUp PrintMyKey})

The following loop is a neverending loop that do nothing
but in background Hollywood is still "listening" for the
; <OnKeyUpevents.
You can exit from this program hitting Control+C
Repeat
   WaitEvent
Forever


I love these Hollywood event handlers
:)

Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Not too shy to talk
Not too shy to talk


See User information
@Allanon

Assuming that you do not want to print the table information every time a key is pressed, but rather the key itself, this would be the code that you want to use instead.

Function PrintMyKey(msg)
NPrint(msg.key)
EndFunction

InstallEventHandler({OnKeyUp = PrintMyKey})

Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Just popping in
Just popping in


See User information
@Atheist

AMOS can not cook coffee that way my Senseo Machine does. What a real let down!
And why the heck does it call "Coffee" Inkey$ ? That is totally confusing to me. I have to learn it all again.

Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Just popping in
Just popping in


See User information
@PEB
Sorry mate, I've made an error copying & pasting the example, ofcourse the intention was to print the pressed key and not the message table.
:)

Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Quite a regular
Quite a regular


See User information
Hi Allanon,

Well, I could NEVER EVER EVER have figured out how to use that command, and I still don't know how to.

Let me explain, keyboard user data entry page didn't tell me about using it as an input possibility, so I would have MAYBE read that page, and my eyes would have glazed over after 2 paragraphs, and I'd have stopped reading it as I couldn't even understand what the command does.

Here's another unknown, I transfered exactly that code into my program, and I pressed the letter "a" 5 times, and this is what was printed on the screen:
Quote:
Table: ox1ad2f168
Table: ox1a60edf0
Table: ox1a60ef30
Table: ox1a60f070
Table: ox1a60f1b0

I have no way at all to even begin to figure out what it means and I tried before I saw that to add an if...then statement in there:

Quote:

Function PrintMyKey(k)
; This function is called everytime the user release a key
if k=5
NPrint(k)
endif
EndFunction




Thinking that "k" is a numerical value, I could get only the number 5 to display when it was pressed, and all other keys would be ignored.



My goal is, take in one key without "return" ending the process, and only the keys that are acceptable as input will be printed.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Quite a regular
Quite a regular


See User information
Hi Hans,

I am using TextOut because in AMOS
Text x,y,"Hello"
prints words MUCH faster than Print and gives me to the pixel placement.

(Continuing AMOS) Print has 80 x 25 character position placement.

Had a problem if you use
locate 79,24
Print "a";

That's the lower right corner of the screen, there would be a carriage return and the screen would scroll up.
There was a command, thankfully, that froze screen raising, however, it wasn't needed with the Text x,y,"a" command.
Another problem was, with print, the invisible cursor would I think in locate 0,0 make an 8x8 blank space at times, or even erase a character.


Edited by Atheist on 2009/1/22 0:18:02
Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Quite a regular
Quite a regular


See User information
Hi PEB,

It looks like I would need a masters degree to figure out that that table needs redirecting that way, I'd never be able to figure out how you did that.

In AMOS I just read it in black and white.

Thank you and Allanon for showing me, as I say, I'd never be able to achieve what I thought was a simple task.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Quite a regular
Quite a regular


See User information
WOW! Woohooo!

One of the few times my experiment worked out!

Quote:

Function PrintMyKey(msg)
NPrint(msg.key)
A$=msg.key
print("Hello "..A$)
EndFunction


I wasn't sure at all if it would work as "msg.key" isn't a string variable. Can periods be used in variable names in HollyWood? I had no idea that they could be used.

So, when I get an acceptable reply, and want to act on it, do I cancel "InstallEventHandler" or "WaitEvent" or both?

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
@Atheist

Quote:

Atheist wrote:
Hi Hans,

I am using TextOut because in AMOS
Text x,y,"Hello"
prints words MUCH faster than Print and gives me to the pixel placement.

(Continuing AMOS) Print has 80 x 25 character position placement.

Had a problem if you use
locate 79,24
Print "a";

That's the lower right corner of the screen, there would be a carriage return and the screen would scroll up.
There was a command, thankfully, that froze screen raising, however, it wasn't needed with the Text x,y,"a" command.
Another problem was, with print, the invisible cursor would I think in locate 0,0 make an 8x8 blank space at times, or even erase a character.


In that case, to do what you want you have to use TextWidth and TextHeight to calculate where your next text output should be. You will have to keep track of the cursor position yourself.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
@Atheist

Quote:

Atheist wrote:
WOW! Woohooo!

One of the few times my experiment worked out!

Quote:

Function PrintMyKey(msg)
NPrint(msg.key)
A$=msg.key
print("Hello "..A$)
EndFunction


I wasn't sure at all if it would work as "msg.key" isn't a string variable. Can periods be used in variable names in HollyWood? I had no idea that they could be used.


No, periods can not be used in a variable name. The variable here is "msg", and ".key" denotes an element within that variable. Basically msg is a table with multiple elements. Look up the section on Tables in the datatypes section of the Hollywoood guide.

Your problem is that this is a totally new concept to you that a variable can have sub-elements.

Quote:

So, when I get an acceptable reply, and want to act on it, do I cancel "InstallEventHandler" or "WaitEvent" or both?


You don't cancel anything. WaitEvent is a function that simply waits until a recognized event happens, and then the correct event handler for that event is called. The event handler is responsible for doing whatever it is that you want with that event. For example, your key handler could check if the key that was pressed is "q", in which case it quits the program.

If you really want to remove an event handler, you call InstallEventHandler with that event set to 0.

Hans


Edited by Hans on 2009/1/22 1:24:55
Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
@Atheist

Here is the example above modified to quit when the user presses "q":

Quote:

Const #TRUE = 1
Const #FALSE = 0
quit = FALSE

Function KeyEventHandler(msg)
; Print the key press
NPrint(msg.key)

if msg.key = "q"
quit = TRUE
EndIf
EndFunction

InstallEventHandler({OnKeyUp = KeyEventHandler})

; Main Loop
While quit = FALSE
WaitEvent
Wend


This should give you a basic idea of how to do event based programming.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Quite a regular
Quite a regular


See User information
Hi Hans,

Convoluted, but I see what it's doing.

Now, if I want the next keyboard user inputs to be one of "N"orth, "S"outh, "E"ast or "W"est, I need to

InstallEventHandler({OnKeyUp = KeyEventHandler})

and reference a different function? "KeyEventHandler" could be "ChooseDirection"?

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
@Atheist

Quote:

Atheist wrote:
Hi Hans,

Convoluted, but I see what it's doing.


It's the standard way of handling events. It's convoluted to you because you're not used to event based programming. Eventually, you should see why it's done this way.

Quote:
Now, if I want the next keyboard user inputs to be one of "N"orth, "S"outh, "E"ast or "W"est, I need to

InstallEventHandler({OnKeyUp = KeyEventHandler})

and reference a different function? "KeyEventHandler" could be "ChooseDirection"?


Put all your keyboard handling code into the function KeyEventHandler. Continue on from the "q" keypress

Quote:
if msg.key = "q"
quit = TRUE
else if msg.key = "N"
MoveNorth
EndIf

etc.


I'm assuming that you've defined a function called MoveNorth, that moves the player north.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
@Atheist Quote:
I'd never be able to figure out how you did that.

Negative thinking does not help you achieve things, nor does under-estimating your abilities. Perhaps you are expecting to work things out instantly, and your failure to do so is leading you conclude that you can't ever do it?

If you changed your mindset, I'm quite sure that you could work out all this & more - it might just take you a LONG while to read, experiment, read some more, more experiments, and so on. Where-as most of us have already done that for *similar* problems (over some years), so we can easily work out how to do that kind of thing again.


Now, maybe you don't have the patience for lots of reading & experimenting, but IMHO that is unavoidable for any programming language *including* AMOS Pro. I should know, because I had the huge tome known as the AMOS Pro manual permanently beside my A1200, and was always referring to it. (This is before I gave-up on AMOS Pro v1.0 being too buggy, especially with floating-point numbers.)

Author of the PortablE programming language.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Home away from home
Home away from home


See User information
Hopefully I didn't just kill the thread... Athiest?

Author of the PortablE programming language.
Go to top
Re: Learning HollyWood (~Tutorial) Vol. 1
Not too shy to talk
Not too shy to talk


See User information
@Atheist

Quote:
It looks like I would need a masters degree to figure out that that table needs redirecting that way, I'd never be able to figure out how you did that.


Well, actually, the guide the comes with Hollywood is very thorough and easy to follow. What I did in that example is simply what is clearly set forth in the Hollywood guide under the section detailing InstallEventHandler().

Go to top

  Register To Post
(1) 2 3 »

 




Currently Active Users Viewing This Thread: 3 ( 0 members and 3 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project