Re: [Ql-Users] Snowfall

2010-11-27 Thread Dilwyn Jones
Thanks - apart from reminding of my days of typing in ZX81 programs 
from magazine listings and then trying to save space (defining 
variables from text values, I seem to recall was one method) you 
have inspired me to fire up my copy of QL2K and try your listing 
out.  I had to use an editor to strip out the CR characters as you 
suggest and then QLAYT.EXE to link the file into my win1_ 
directory.


It mostly works until density% becomes 5 at which point it fails at 
line 310 with bad parameter, presumably because it is trying to 
do a RND(1 to 0).


Any suggestions?



Well spotted!

(snip)

Should work with changing that line to 310 IF RND(1 TO 6-density%)=1 
THEN
which should make sure it gives a snow density of 1 to 5, whichis 
what I'd intended.


Just tried it on QemuLator and that seems to work.

I suppose next step is to make the snow get plotted with OVER -1 so 
that the XOR effect could work over a background picture.


Just noticed as well how much QemuLator slows down while I'm typing 
this email - the snowfall has become, well, almost standstill snow!


Dare I say  that's snow good ;o)

Dilwyn Jones



___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Norman Dunbar
 This meets all Rich's requirements:
 --
 The rules are simple -
 write out the values 1 to 100 on screen
 If the value is divisible by 3 write 'FIZZ' after the number
 If the value is divisible by 5 write 'BUZZ' after the number
 If the value is divisible by 3 and 5 write 'FIZZBUZZ' after the number
 --
 Nothing about having to stop at 100 (8-)#

But, I'm sure the request was for assembly language programs, not
SuperBasic? Hence the subject line in this thread?

Just a thought! ;-)


Cheers,
Norman

-- 
Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL

Company Number: 05132767
___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Norman Dunbar
On 26/11/10 21:48, Tobias Fröschle wrote:

 main(){for(;;i++){puts(!i%3)?FIZZ:(!(i%5)?BUZZ:));}}
Error!

Puts() needs #include stdio.h or at least defining correctly!
Main() always returns int.
Main always takes two parameters int and char **.
Your main() function doesn't return a value.

The correct (?) version would then be something like:

#include stdio.h
int main(int argc, char
**argv){for(;;i++){puts(!i%3)?FIZZ:(!(i%5)?BUZZ:));}return 0;}

Slightly longer now and I still haven't #included the header for puts()
to work correctly.

Plus, do we count the bytes in stdio.h as part of the program? I rather
suspect we should.

Reducing it to the minimum would be:


int puts(s)
char *s;
int main(int c, char
**v){for(;;i++){puts(!i%3)?FIZZ:(!(i%5)?BUZZ:));}return 0;}

or

int puts(char *s);
int main(int c, char
**v){for(;;i++){puts(!i%3)?FIZZ:(!(i%5)?BUZZ:));}return 0;}

:-)


 And is of course way more readable, structured, object-oriented and
 modern as well.
Indeed! ;-)


Cheers,
Norman.

-- 
Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL

Company Number: 05132767
___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


Re: [Ql-Users] A small machine code program...

2010-11-27 Thread gdgqler

On 27 Nov 2010, at 13:25, Norman Dunbar wrote:

 This meets all Rich's requirements:
 --
 The rules are simple -
 write out the values 1 to 100 on screen
 If the value is divisible by 3 write 'FIZZ' after the number
 If the value is divisible by 5 write 'BUZZ' after the number
 If the value is divisible by 3 and 5 write 'FIZZBUZZ' after the number
 --
 Nothing about having to stop at 100 (8-)#
 
 But, I'm sure the request was for assembly language programs, not
 SuperBasic? Hence the subject line in this thread?
 
 Just a thought! ;-)

Probably correct. Though I wonder how many machines other than QL would allow 
Marcel's fantastic one lined SuperBASIC program to operate  immediately by 
typing in the line and then RUN.

George
___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Tobias Fröschle

Am 27.11.2010 15:48, schrieb Norman Dunbar:

On 26/11/10 21:48, Tobias Fröschle wrote:


main(){for(;;i++){puts(!i%3)?FIZZ:(!(i%5)?BUZZ:));}}

Error!

Warning!

Puts() needs #includestdio.h  or at least defining correctly!

It should, for the sake of art, but doesn't need to.

Main() always returns int.
Main always takes two parameters int and char **.
It should, to generate anything maintainable, but doesn't need to. C 
allows you to ignore return values.

Your main() function doesn't return a value.

The correct (?) version would then be something like:

#includestdio.h
int main(int argc, char
**argv){for(;;i++){puts(!i%3)?FIZZ:(!(i%5)?BUZZ:));}return 0;}


And is of course way more readable, structured, object-oriented and
modern as well.


I can do even better (alas, not on the QL - And: I'll probably never get 
employment as a Java programmer):


/*
 * FuzzBuzz.java
 */
package fuzzbuzz;

/**
 *
 * @author tofro
 */
public class Main {
public class Fuzzer {
int divisor;
String infoStr;
public Fuzzer(String info, int _divisor){
infoStr = info;
divisor = _divisor;
}
public void test (int i){
if ((i % divisor) == 0){
System.out.println(i + infoStr);
}
}
}

private Fuzzer fArray [] = new Fuzzer[2];

Main(){
fArray[0] = new Fuzzer(FUZZ, 3);
fArray[1] = new Fuzzer(BUZZ, 5);
}

public void test (int i){
for (int j = 0; j  fArray.length;j++){
fArray[j].test(i);
}
}
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
Main m = new Main();
for (int i = 0; i  100 ;i++){
m.test(i);
}

}
}

___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


[Ql-Users] Why we can't code (Re: A small machine code program...)

2010-11-27 Thread Marcos Cruz
En/Je/On 2010-11-27 16:33, gdgqler escribió / skribis / wrote :

 I wonder how many machines other than QL would allow Marcel's fantastic one
 lined SuperBASIC program to operate  immediately by typing in the line and
 then RUN.

Beside the QL, I use the following three machines, and all of them allow that:

ZX Spectrum (1982):

1 FOR i=1 TO 100: PRINT i,FIZZBUZZ(1+4*(i/3-INT (i/3)0) TO 4+4*NOT (i/5-INT 
(i/5))): NEXT i
RUN

Jupiter Ace (1982):

: GO 101 1 DO I . I 3 MOD 0= IF . FIZZ THEN I 5 MOD 0= IF . BUZZ THEN CR 
LOOP ;
GO

SAM Coupé (1989):

1 FOR i=1 TO 100: PRINT i,FIZZBUZZ(1+4*(i MOD 30)TO 4+4*NOT i MOD 5):NEXT i
RUN

But there are many more -- in fact most old micros.

I think it's sad we were able to do that with most micros of the 80's, while
we certainly cannot with any modern computer. Nowadays we have to install a
bloated and complex OS and a bloated and complex programming language in order
to type one single command! That's one of the many reasons I love
retroprogramming so much.

I remember an excellent article I read some months ago, concerning this issue.
Its title is Why Johnny can't code:

Original by David Brin:
http://www.salon.com/technology/feature/2006/09/14/basic/

Reviewed by Kroc Camen:
http://www.osnews.com/story/23464/Why_Johnny_Can_t_Code


Marcos

-- 
http://alinome.net
___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Marcel Kilgus
Norman Dunbar wrote:
 Main() always returns int.

True.

 Main always takes two parameters int and char **.

Not true, int main(void) is valid according to C99 spec (see chapter 
5.1.2.2.1 ;-) )

But in context of the IOCC contest Tobias referred to, basically
everything that compiles is valid (his example doesn't really work in
any case). Though they're usually much worse, this for example is an
actual winning entry from 1988:

main(t,_,a)
char *a;
{return!0t?t3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t_?main(t+1, _, a ):3,main ( -94, -27+t, a
)t == 2 ?_13 ?main ( 2, _+1, %s %d %d\n ):9:16:t0?t-72?main(_,
t,@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/)
:t-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0t?main ( 2, 2 , %s):*a=='/'||main(0,main(-61,*a, !ek;dc \
i...@bk'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry),a+1);}

Guess what it does? Why yes, it prints the complete lyrics of the song
The Twelve Days of Christmas! No kidding, I just tried it myself
(the actual entry was a bit differently formatted but in no way more
readable):

On the first day of Christmas my true love gave to me
a partridge in a pear tree.

[...]

On the twelfth day of Christmas my true love gave to me
twelve drummers drumming, eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

Cheers, Marcel

___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


Re: [Ql-Users] Snowfall

2010-11-27 Thread Stephen Meech

On 27/11/2010 11:28, Dilwyn Jones wrote:

It mostly works until density% becomes 5 at which point it fails at
line 310 with bad parameter, presumably because it is trying to do a
RND(1 to 0).


Well spotted!



Should work with changing that line to 310 IF RND(1 TO 6-density%)=1 THEN
which should make sure it gives a snow density of 1 to 5, whichis what
I'd intended.


That's what I did - 5 seemed arbitrary anyway.


When I figure out how to copy it from QPC to QemuLator (floppy disk?) or
QL2K I'll test it in QDOS. Just goes to show the dangers of assuming
that because it ran OK on one computer doesn't mean it'll always run OK
on another!


I'm using QL2K.
--
Regards,

Stephen
___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm


Re: [Ql-Users] Why we can't code (Re: A small machine code program...)

2010-11-27 Thread Tony Firshman

Marcos Cruz wrote, on 27/Nov/10 18:12 | Nov27:




I remember an excellent article I read some months ago, concerning this issue.
Its title is Why Johnny can't code:

Original by David Brin:
http://www.salon.com/technology/feature/2006/09/14/basic/

Interesting but awful page coding.
There was an ad which I couldn't close - the 'x' did not respond.
One had to click elsewhere!
Also there was an auto-starting sound file that was not linked to any of 
the videos.

Arghh.
I must confess I closed the window after only glancing at it.


Reviewed by Kroc Camen:
http://www.osnews.com/story/23464/Why_Johnny_Can_t_Code


Tony

--
QBBS (QL fido BBS 2:257/67) +44(0)1442-828255
   t...@firshman.co.uk http://firshman.co.uk
Voice: +44(0)1442-828254 Fax: +44(0)1442-828255 Skype: tonyfirshman
TF Services, 29 Longfield Road, TRING, Herts, HP23 4DG
___
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm