That's what I'm talking about! Thanks to the Macros everyone could easyly write his own Str(). I think this would be the best.CompilerTypeIf <varname> = <typeconstant>
...
CompilerEndIf
PureBasic - really pure? For example: Str()-Function
-
- Enthusiast
- Posts: 212
- Joined: Fri Apr 22, 2005 2:07 pm
- Location: U.S.A.
- Contact:
Str() function
I think it is good to keep track of the variable type. A universal command would be nice, but I've found it helpful to know what type of variable I'm dealing with.
What is StrQ() and why is it not in the help files?
What is StrQ() and why is it not in the help files?
-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Str() function
You're dealing with a string type, aren't you?PB&J Lover wrote:... I've found it helpful to know what type of variable I'm dealing with...

A universal Str could be nice sometimes, but I think, it is also ok as it has been implemented yet (contrary to the "rounding" functions

-
- Enthusiast
- Posts: 212
- Joined: Fri Apr 22, 2005 2:07 pm
- Location: U.S.A.
- Contact:
STR() function
Yes, I meant what type of varible I'm converting to a string.
I do agree about ROUND() it should be enhanced to round properly.
Love PB though
I do agree about ROUND() it should be enhanced to round properly.
Love PB though
-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
-
- Enthusiast
- Posts: 212
- Joined: Fri Apr 22, 2005 2:07 pm
- Location: U.S.A.
- Contact:
PB & C
Well, that would be incorrect. PB is not closer to C++ than BASIC. It is sort of a hybrid, but it is definately a form of BASIC.
That's C++. Even your example is nothing like BASIC or PureBasic. This is the above code in PB.
If you don't think that PB is the best (or one of the best) languages to come down the pike, you're not doing it right. 
Code: Select all
/*Hello World Program */
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
Code: Select all
; Hello World Program
openconsole()
printn("Hello World")
closeconsole()

-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
well, isn't that what programming is all about?chris319 wrote:Why not just have ftoa, dtoa, ltoa and qtoa and admit that PB is closer to C than BASIC?
Yeah great, just what we need, a do-it-yourself language.Thanks to the Macros everyone could easyly write his own Str().

i mean, why ARE we writing our own little games, when there's half life 2? why are we writing our own text editors, when there are tons of editors out there? why are we using purebasic, when there are countless other basics out there?
yes, there are some things very wrong with purebasic
yes, there are some things incredibly right with purebasic
you might consider adding a few 'oh, i would like' 'perhaps it would be good idea' and 'in my opinion'
because for some of us it's a hobby, for others it's their work, and for some of the remainder it's another subject in their miserable lifes they can complain about (my apologies for my somewhat emotional response, but the board has been suffering from whining lately, and i admit i did have a bad day yesterday)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Yes, my 16 bit GFA does most things faster than PB, especially numerically intensive software, such as complex calculation and simulation.Slower? I've just done a test with my 20+ years old 16 bit GFA (yes, again) - the universal Str-Function is far more than 3 times faster - now I'm a little bit nervous...
But PB4 can do just about everything I want to do, math, Internet, access to Win32 etc, and it works reliably.
I never had a GFA compiler that was reliable, and worst of all the compiler and interpreter created different code, so you never knew that code which you had debugged would work when fully compiled. I don't think that GFA ever got the 16 bit paged addressing working 100%
Now that Purebasic has doubles, I find it hard to fault.
As for speed, Purebasic is as fast as GFA on some things and maybe half the speed on some integer maths. But the PC I use now is 50 times as fast as the one I had when I purchased GFA, so no problems.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Read my post, I am not criticising Purebasic, I love it.Might you seriously demonstrate that to the forum, please?
I can easily post a little numerical bench test that is faster in GFA than PB but what does this prove? People will say that the test is not representative of typical modern computing, and they would probably be right. Of course, you can't program a typical modern task in GFA because you don't have convenient 32 bit DLL access and so on.
But many years ago I wote a simple numerical benchmark that I have tested on many computers, including very large mainframes and using many computer languages, compilers and interpreters. The benchmark is very simple but is a good guide to the performance of computers and software in running finite element numerical modelling tasks. This was done long before GFA was available.
The results are that Purebasic is slower than GFA at this task. In fact the fastest language was an old Fortran compiler and second fastest a modern C compiler. Various version of Basic were tried and GFA was found to be the fastest of those tried but around 20% slower than the best C compiler and 50% slower than the best Fortran compiler. I consistently found all versions of Pascal to be rather slow.
-
- Addict
- Posts: 841
- Joined: Mon Jun 07, 2004 7:10 pm
My idea (if not mentioned before):
Code: Select all
Str(var1,#PB_String)
Str(var2,#PB_Long|#PB_Unsigned)
Str(var3,#PB_Float)
Str(var4,#PB_Quad|#PB_Unsigned)
-
- Enthusiast
- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
Don't all get hung up on speed.geoff wrote:The results are that Purebasic is slower than GFA at this task. In fact the fastest language was an old Fortran compiler and second fastest a modern C compiler. Various version of Basic were tried and GFA was found to be the fastest of those tried but around 20% slower than the best C compiler and 50% slower than the best Fortran compiler. I consistently found all versions of Pascal to be rather slow.
Speed isn't important anymore in computing, unless a compiler is so bad ... in which case nobody would use it!
The programmer should decide the tool to use based on it's ability .. speed, ease of use, reusable code... etc...
Games used to be written entirely in assembler, because anything else was too slow. Now they are written in all different languages, C C++ seem to be the most common these days....
But, if the programmer needs more speed he can still code parts of his app/game in Assembler for a boost.
Funny enough, Purebasic provides this feature too!!!
I bet GFA basic, or any other language, cannot do anything as fast as PB's inline ASM... unless they have this feature too, and then it would be a draw!
If you think PureBasic is too slow.... Upgrade your processor


Paid up PB User !
-
- Enthusiast
- Posts: 468
- Joined: Sat Dec 20, 2003 6:19 pm
- Location: Switzerland
I mostly agree with you, but a friend bought a really new and fast processordontmailme wrote:Speed isn't important anymore in computing, unless a compiler is so bad ... in which case nobody would use it!
a week ago and told me, that he is disappointed, WindowsXP and most
other programs don't run faster on it than WindowsME did on it's old PC.
I think we should really also consider speed important and not just update
hardware because it can "solve" the problem.
@Topic:
As there is Defined(), SizeOf() and OffsetOf(), there should also be a
TypeOf()

greetz
Remi
Athlon64 3700+, 1024MB Ram, Radeon X1600
I don't agree, it's not because you have computing power you have to waste it. About this thread, it's getting silly, all is about one command, which isn't speed critical. I could probably optimize it and get some speed increase, the big question is: does it worth all the time needed for doing it (instead of doing more important/useful things) ?
Absolutely right, who would need ultra fast string creation?all is about one command, which isn't speed critical
I reckon that a small subset of a language needs to be fast to speed up most applications.
For example.
1) Loops and conditional tests
2) Array access (ie fast address calculation)
3) Equation solving (formula translation) and efficient use of FPU
4) File system access
If the compiler is optimised, then these core elements may be faster than assembler routines you write yourself.
Most of the complex stuff in a language is there to save programming effort. For example convenient Windows API access, complex data structures, network access. Much of this does not need to be lighning fast.