Page 1 of 2
Standard 'C' Functions
Posted:
Sat Apr 22, 2006 5:11 pm
by Just4Fun
Just out of curiosity,
Can someone tell me which standard 'C' functions
can't be used with GE?
For example: I can't use printf or scanf... what other standard functions can't be used to build programs in the global editor?
TIA
Posted:
Sat Apr 22, 2006 5:31 pm
by Fuzzy
if you can find source code that shows how to build printf, you might able to port it to GE. After all, those are just functions like any other.
Posted:
Sat Apr 22, 2006 5:59 pm
by Just4Fun
Hi ThreeFingersPete:
Does your answer mean that I would put the printf statement into a function and call it from the global editor? I've tried to build printf before just to see if I could do it and I didn't have any luck so I assumed that it could not be used.
At one point Makslane said,"There is no support for printf in Game Editor. "
So I assumed that what I was doing was impossible. It would be great to get a list of standard 'C' functions together that can't be used so that we don't spin our wheels trying. I know that there are simple ways to do this stuff in GE, but sometimes I want to try using a little 'C' code for learning and for fun. I'd also like to use GE for more than games and that requires more 'C'. TIA
Posted:
Sat Apr 22, 2006 7:23 pm
by Fuzzy
Nope. What I mean is that somewhere back in the mists of time, someone built printf using the basics of C, or more likely, assembler language. If Makslane says its not possible, it may very well be not possible.
However, a lot of the advanced commands in C and GE are just functions made with the basics of if, while, variables...
Sometimes you can reinvent the wheel, so to speak. Until Makslane decides its worth his while to add a function like printf, we must work our way around the limitations.
At a certain point, the people that created C decided "this far, and no more" and let the programmers create what they needed. Most of what C allows for is already in GE. What seems to be missing is port calls and whatnot, low level graphics card access would be an example.
Things like Printf are just functions bound up in a library and uncluded as a collection. when you go to global code and save a group of stuff there, thats about what a library is. There are sources to read how Printf is set up.
look around in here...
http://en.wikipedia.org/wiki/C_standard_library
Posted:
Sat Apr 22, 2006 8:16 pm
by makslane
The printf function print a text in the standard text output.
There is no standard text output in Game Editor, so, use printf make no sense.
But you can use the sprintf function and update a text actor.
Posted:
Mon Apr 24, 2006 2:47 am
by Just4Fun
Ok. We know that we can't use printf. So I have one function to add to my can't use list. What are other functions that we can't use? Anyone care to add to the can't list? TIA
Posted:
Mon Apr 24, 2006 4:19 am
by Fuzzy
Here is a list of keywords for C. Some wil be in GE, some will not. I will point out the ones i know are not part of GE.
asm - not in GE - used to link assembly instructions
auto - I have no idea... a car?
break - GE!
case - GE
char - GE
const - I'll have to try this..
continue - not sure
default - no, I think
do - yup, GE
double - yup
else - yup
enum - I think so. I had partial success with this, and it can do really neat things. You hardly ever see it used.
extern - nope. for linking libraries
float - yup
for - you bet! GE all the way
goto - I THINK so
if - my mortal enemy, a verified resident of GE
int - yep
long - yes
register - no. for direct access to CPU
return - I am happy Just4Fun has returned! GE compatible, and so is return
short - yes
signed - yes
sizeof - for arrays i think? or strings? used in GE
static - uh... no?
struct - never seen it in GE, but Makslane uses it to make GE!
switch - dont use if, switch to switch in GE!
typedef - nope. never seen in GE
union - unlikely in GE
unsigned - yes
void - yes in GE
volatile - i think this refers to shared port resources, so is not in GE
while - Worth your while to use in GE
I might be off on some of these things. It never hurts to look them up. Everything you see in C that is not in this list was created with these 30+ items.
Posted:
Mon Apr 24, 2006 4:48 am
by WauloK
i wonder if other defines are in GE.
ifdef
ifndef
endif
Posted:
Mon Apr 24, 2006 6:04 am
by DilloDude
ThreeFingerPete wrote:if - my mortal enemy, a verified resident of GE
What is it you don't like about ifs?
Posted:
Mon Apr 24, 2006 6:56 am
by WauloK
possibly a 'switch' fan?
Posted:
Mon Apr 24, 2006 8:32 am
by Fuzzy
Definately a switch fan.
I dont mind ifs, really, its just me being silly.
On the other hand, if you choose to limit your options, you will find that you gain strength and creativity. When I run into a situation where I think I need an if statement, or a while, or whatever, I stop and think: Can I do without this step?
Doing so certainly tightens up code. You will often see a beginning programmer use 11 ifs in a row... if A = 0... if A = 1.... thats understandable, but note the last line; if A = 10....
You dont need that last if, as long as you prepared things so A can only ever be 0 through 10. Often you are using a loop!
We all learn to step past this; we become intermediate programmers, and consider ourselves wise, but tell me this: are we still doing things that a master would say is silly?
So I limit myself. I challenge myself to do without, in hopes that I can find some novel and hopefully efficient way to do what I need. Sometimes I fail, but the trying teaches me things.
Posted:
Mon Apr 24, 2006 12:43 pm
by WauloK
similar to 'real coders' hating 'goto' in languages...
Posted:
Mon Apr 24, 2006 2:34 pm
by Just4Fun
An interesting thread. ThreeFingersPete... thanks for adding what you do know. I can see that I really need to dig into some 'C' to test some of this stuff. Would people add to the list as they discover what doesn't work? I am focusing on what doesn't work because I *think that list would be a lot shorter than what does work.
WauloK: "goto" was pretty popular in the 'olden/golden' days of programming. I've seen several books that talk about spagetti code and some that actually still try to 'sell' it. It can have some application in rare circumstances, but I think most 'real' and probably most 'unreal' programmers would agree with you.
The whole subject of goto is kind of interesting.
I also like the "switch" statement. It seems to make things more readable,but "if" works and is sometimes easier for eternal beginning programmers like me to understand.
Thanks for getting some scripting discussion going in the forum. I have also enjoyed and learned from the #Define discussion. I hope that as people learn, they will share with the rest of us... TIA to all the great GE people!
Posted:
Mon Apr 24, 2006 8:01 pm
by Fuzzy
You know whats missing from that list? getch and putch.... but i think they make use of the register keyword, so would be secondary functions...
Posted:
Mon Apr 24, 2006 9:39 pm
by WauloK
Just4Fun wrote:WauloK: "goto" was pretty popular in the 'olden/golden' days of programming. I've seen several books that talk about spagetti code and some that actually still try to 'sell' it. It can have some application in rare circumstances, but I think most 'real' and probably most 'unreal' programmers would agree with you.
The whole subject of goto is kind of interesting.
Yeh. I was a member of the 'golden olden' days programming
Started on computers about 22 years ago, programming in BASIC and Assembly. They both have a 'goto' type command