printf(" string 2 = %s\n",my_values.str2); printf(" value 1 = %d\n",my_values.value1);
If you need a table of grouped variables you can do that like this:
struct my_value_type my_values[50];
Hi LiveForIt,
I have made a 4 dimensional array in AMOS, as well as many many other arrays and have no problem whatsoever manipulating them.
Mind you they are simple retrieval systems, character so-and-so's gold, or age or hit points, what-not, not image manipulation or anything like that.
I find it very easy to set up, use, manipulate. However that thing there makes no sense to me at all. And it was attempted to be explained to me before, but I found ZERO benefit to me over how I do it in AMOS, also not understanding it doesn't help either.
To me char *str1; means multiply "char" with "str1".
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.
I have to apologize, but, I'm stupid. (jahc is determined to believe that about me so I'll oblige him.)
Dont twist my words. I said expecting to understand a new programming language without learning it first.. THAT is stupid. Every time you bring this up, I post my link to C programming tutorials. I discovered Allegro recently, so I thought I'd mention it because its an easy way to do graphics and sound for games. I dont know what more I can say. I'm just repeating myself over and over.
My complaint was that there doesn't seem to be an easy language to use at the moment on AOS4.0.
C was only brought up that I don't understand it, and PortablE for me, is 95% similar.
The other languages, Pascal and Lua expect me to set up SDK, which is not something I can do, at least I doubt I can.
C is required for certain things, as is assembler. I'll never be capable of using those unless someone creates some new type of C.
I've seen brain breaking conversations, on just how to set parameters to compile a program.
SDL Basic didn't work, I can't remember why, it was a long time ago that I tried to use it, and Brandy just won't do certain instructions properly, and is limited, as it ISN'T aware of what abilities AmigaOS has and doesn't offer the instructions to take advanage of them.
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.
Dont twist my words. I said expecting to understand a new programming language without learning it first.. THAT is stupid.
Hi jahc,
I misunderstood. Sorry.
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.
I forgot to add about the total waste of time, perpetual semi-colon typing.
The things that you see as "waste of time" are in fact things that help you reduce the number of bugs in a program. Declaring the type of a variable (e.g., number is an integer: int number;) helps to ensure that you don't do something stupid with it. Semi-colons denote the end of an actual line of code, which can be multiple lines long.
As to how easy it is to draw a pixel to the screen in Amos, that's due to Amos' library of built in functions. The standard C library provides only a few basic functions for text and file handling. If you use something like Allegro (as Jahc suggested) then you have a lot of powerful and easy to use functions.
So why doesn't C come with an Amos like runtime library? Because most people want to program closer to the underlying system instead of having yet another layer between them and the OS/hardware.
C was only brought up that I don't understand it, and PortablE for me, is 95% similar.
Sad to hear, but you do not seem prepared to accept any "overhead" (nevermind that this is a tiny part of any normal program). So we can conclude that most modern programming languages are no good for you.
You are only going to find what you want in one of two places: 1. Another language based on BASIC.
2. A scripting language, which are usually designed for short "toy" programs. Something like (say) Hollywood.
Quote:
I've seen brain breaking conversations, on just how to set parameters to compile a program.
I'm not sure how you can get any simpler than AmigaE:
So why doesn't C come with an Amos like runtime library? Because most people want to program closer to the underlying system instead of having yet another layer between them and the OS/hardware.
That's wrong IMHO. Rather the answer is that C left it up to the user as to what abstractions (commands) they use. It could be Allegro, it could be SDL, or it could be something they wrote themselves.
So someone could wrote a set of C (or E) functions that looked almost identical to AMOS commands. In fact E already has stuff like Plot(), Line(), etc built-in, and those are probably already quite close to AMOS & other BASICs.
Sorry, I thought that the "include" stuff was missing, as well as the millions of semi-colons, and brackets.
In addition to that, I can't even relate to when to use the brackets and NOT to use them (at least in the "C" code I've looked at). This applies to the semi-colons even.
If you bothered to buy a "Learn C" book (hint, there is a "C for Dummies book," but I don't know how well/bad it's written). then this would quickly become second nature.
To spell it out, this is BASIC:
IF X = 10 THEN gosub drawCar ELSE gosub drawPig ENDIF
this is C:
if( x == 10) { drawCar(); } else { drawPig(); }
Similarly, brackets denote the start and finish of a for/while loop and enclose the contents of a function.
Quote:
C code looks like someone who's lost the ability to talk.
As long as you can't be bothered to learn, it will always look like that. Chinese script is incomprehensible to me, yet others can understand it like it were obvious. If I took the time to learn, I'm sure that I'd eventually be able to read it as easily as English.
So why doesn't C come with an Amos like runtime library? Because most people want to program closer to the underlying system instead of having yet another layer between them and the OS/hardware.
That's wrong IMHO. Rather the answer is that C left it up to the user as to what abstractions (commands) they use. It could be Allegro, it could be SDL, or it could be something they wrote themselves.
You've said almost the same thing but in a different way. C was meant to allow you to program the hardware directly. This means that a high level runtime library such as Basic provides is wasted. I was trying to give an idea as to why someone would write a programming language without providing a BASIC style runtime library. The BASIC style library is too limited for the kind of stuff that I want to do.
To be honest, Basic doesn't provide a standard runtime library either. IIRC, C64's BASIC didn't provide the plot function either. Every variant of BASIC has its own set of available functions.
@Athiest ONE LAST TRY TO CONVINCE YOU TO GIVE AMIGAE A TRY: I have rewritten my previous "plot" example. Surely even you will agree that it is quite simple:
Quote:
MODULE '*athiest'
PROC main() openWindow(320, 200)
Plot(159, 99, 2)
waitForUserToCloseWindow() closeWindow() ENDPROC
Why does it look so different? Because I have put all the "complicated overhead stuff" in a separate module (a file), which you need never look at! But since you may wish to run the above example, you at least need to see it once, to copy & paste it into a file called "athiest.e" :
PROC openWindow(width, height, x=0, y=0, title=0) window := OpenW(x, y, width, height, IDCMP_CLOSEWINDOW, WFLG_CLOSEGADGET OR WFLG_ACTIVATE, IF title THEN title ELSE 'window', NIL, 1, NIL) IF window = NIL PrintF('ERROR -- Could not open window!\n') Raise("WIN") ENDIF ENDPROC
PROC closeWindow() IS CloseW(window)
PROC waitForUserToCloseWindow() WHILE WaitIMessage(window) <> IDCMP_CLOSEWINDOW ENDWHILE ENDPROC
You now need to type this once in a Shell: EC athiest.e
One last comment. If you use a proper IDE (e.g., Cubic IDE) then all the complexities of make files and how to compile your program are hidden behind the editor. Cubic IDE writes the makefiles for you, and its default configurations are pretty good.
Cant a smart IDE detect OS 3 compatibility setting and switch/replace certain functions with OS 3.x ones ?
Probably, but I doubt it will be much quicker than doing it manually, plus you have other functions that don't have direct equivalents. A better way is to write some compatibility functions that emulate the new ones, but even then you will struggle if you try to use new features of functions through the use of new tags.
@ChrisH
Quote:
ARexx actually looks like quite a nice language, but after some time programming in it I concluded that it was not suitable for large (or even medium) sized programs - most probably because it shares too many of BASIC's flaws.
AmiPodder is written in ARexx, so it is certainly capable. You can get graphics libraries for it so I suppose you could write a game in ARexx. It would be a bit slow though.
@BrandonLee
Quote:
Every variable needs to be declared in C, which was not the case in BASIC, for example. But the major confusion is clearly handling pointers.
It depends which BASIC you are talking about - some insist on variables being declared. C pointers are a PITA, completely agree there.
@allanon
Quote:
... I can add the following examples
--- LUA --- number = 5
--- Perl --- $number = 5;
--- ARexx --- /* set number to 5 */ number = 5
--- Installer --- (set number 5)
All complete examples.
@Atheist
Quote:
Let's say I want to change the colour of one pixel, what all do I need to type in C
WritePixel(rastport,x,y);
Of course, that's not a complete example, which would be more like this: // Compile with gcc -o pixelplot pixelplot.c -lauto
Which is obviously completely ridiculous, as the pixel plotted will end up over the window border (if it has a border, which we can't know for sure), we don't know what colour it will be, and the whole caboodle is left on screen after the program exits.
ARexx actually looks like quite a nice language, but after some time programming in it I concluded that it was not suitable for large (or even medium) sized programs
AmiPodder is written in ARexx, so it is certainly capable.
I did not mean that you CANNOT write large programs in ARexx, but just rather that it would be a very difficult & bug-prone experience. A bit like trying to write everything in PPC assembler - possible, but you would be mad to do so.
Semi-colons denote the end of an actual line of code, which can be multiple lines long.
Hi Hans,
Reading the above, therefore: Quote:
Hans wrote: this is C:
if( x == 10) { drawCar(); } else { drawPig(); }
to me becomes (and can only make sense) by your own rule:
if( x == 10){drawCar(); } else { drawPig(); }
And that last bracket seems to be missing the semi-colon. This is why I can not understand C. I can not understand why there isn't a semicolon to the right of the final bracket??
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.
You guys keep complaining about debugging. I wrote over 4000 instructions in that program I made, and there were very few errors. A bit of trial and error found them fairly quickly.
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.
Interestingly, I only used procedures because the code was getting so long, that the "folding" feature was what I wanted to exploit, otherwise the whole thing would have been composed of gosubs and gotos.
In fact, if Gosub.... Return was foldable, that's how I would have done it.
I found some problem, it wasn't doing global and local variables correctly. I think that inside procedures I wasn't able to export locals or something (whatever it was, it was very annoying that I couldn't achieve what I wanted). It was a long time ago, can't remember exactly. So I just pretty much made almost all my variables global.
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.
I just remembered, I wish that If... Then statements were foldable, I had one that had 250+ lines it it, what a nuisance that was skipping over, back and forth going up and down the code list!!!!
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.
@Atheist I would class a 4,000 line program as being small (edit:or maybe small-medium). By comparison, PortablE is composed of maybe 50,000 lines of code, although probably only 35,000 are specific to PortablE (the rest being general-purpose stuff that I can reuse in other programs).
But still, if you had very few bugs, then your program cannot have been doing anything complicated IMHO. Either that or you are a genius... (I can see jahc fainting already!)
Quote:
I just pretty much made almost all my variables global.
This is VERY bad programming practice.... but it is also very common in BASIC programs. Here's a program I wrote in a BASIC-like language a few years ago, which had more globals than I would have liked: http://freepoc.org/viewapp.php?id=60
And I can tell you now that BASIC was the WRONG language to program it in. However, it still (mostly) worked, it was just a severe pain to write. Doing it in AmigaE would have been much much easier.
P.S. I would appreciate a comment on what I write in post #91.
Edited by ChrisH on 2009/1/14 0:44:16 Edited by ChrisH on 2009/1/14 1:46:19