Qbasicnews.com
April 12, 2021, 07:23:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2] 3
  Print  
Author Topic: Strange results in FB with PRINT USING.  (Read 10069 times)
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #15 on: August 01, 2005, 04:43:51 AM »

I put it together in 2001 using a bunch of really sloppy perl scripts to first split the megabyte or so of QB's help files into different sections, and then convert them to HTML.

I should update it so it uses proper unicode and stores the files in a database so other sites can use it.  I'll get to it sometime when it isn't 1am.
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #16 on: August 11, 2005, 09:14:00 PM »

Quote from: "Jofers"
I don't know.  The C source code from the runtime library can be downloaded for free from http://www.freebasic.net, anyone willing to patch it should do so.  I doubt v1ctor or one of the other developers will, because they added PRINT USING just to be backwords compatible.

Also, anyone is free to edit the documentation, as it is a wiki.

Jofers,

I've been puzzled by your above post for days. I've never worked with open source software before, so I don't understand what you meant by "anyone willing to patch it should do so."

If someone did patch it, would this patched version be his own personal version, or would it become part of the official FB version that everyone else is going to use?

Assuming that the patch version now becomes part of the official FB version, isn't this kind of patching dangerous by anyone without supervision, authorization, testing, etc.?

Or, am I missing soemthing? Please clue me in.
*****
Logged
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #17 on: August 11, 2005, 10:15:43 PM »

you patch it, send it to the devs, and they add it Wink  (or you add it to the rfe section of the sourceforge project page and upload the patch as an attachment)
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #18 on: August 11, 2005, 10:18:43 PM »

Well, the runtime library is under the GNU Lesser General Public License; you can find more information about it and the other license used for the compiler itself, the GNU General Public License, at http://www.gnu.org/licenses/

If someone were to, say, patch PRINT USING so that it acts in a QB-compatible way, they would normally send their code to a developer (most likely v1ctor) to add to the current official source, if it is verified to do what it claims to do, etc.  Only the developers (specifically, the ones listed at http://www.sourceforge.net/projects/fbc ) are able to make changes to the official source code using CVS.  However, anyone is welcome to write new code, fix bugs, etc., as long as the end result is licensed as specified in the LGPL.  You retain the copyright to any code you write, but you must also follow the terms of the LGPL.
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #19 on: August 11, 2005, 11:07:57 PM »

Thanks, DrV, that makes a lot more sense.
*****
Logged
mjs
Member
*
Posts: 40


« Reply #20 on: August 16, 2005, 04:21:46 PM »

In the next FB release, there's a FORMAT$(num#, mask$) implementation available as soon as you include "vbcompat.bi".

This should be a bit more flexible and supports internationalized numbers, date, times, month- and weekday names.

Regards,
Mark
Logged
rpgfan3233
Ancient Guru
****
Posts: 617



« Reply #21 on: August 17, 2005, 02:58:46 AM »

Quote from: "mjs"
In the next FB release, there's a FORMAT$(num#, mask$) implementation available as soon as you include "vbcompat.bi".

Never used VB (meaning I haven't used the Format function), but it looks like a nice alternative to USING.
Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
rdc
Senior Member
**
Posts: 176



WWW
« Reply #22 on: August 17, 2005, 09:56:04 AM »

Format$ is great. I used it all the time when I did professional VB work. This will be a great addition to FB.
Logged

paleozord
Member
*
Posts: 57


« Reply #23 on: August 25, 2005, 01:36:14 AM »

I'm not sure why PRINT USING is considered such an antiquated and obsolete command. It is the ONLY way to print formatted text so that it lines up the way you want it in Basic, and it is probably the single most useful and important command in any text game.

Printf and Sprintf are meaningles to me, because I have no idea what crt.bi is or what including it means.

Format$ looks equally unappealing, again because you have to "include" something called vbcompat.bi.

I have no idea what C source code or a runtime library is, since I'm just a QBasic programmer, period. So I have no idea how to "patch" anything.

For me, the beauty of BASIC is how useful and simple it is on its own, without any additional libraries, included files, or patches.  FreeBasic's largest appeal will probably be to those migrating directly from QBasic to a version that is more Windows compatible, so personally I think that 100% backward/identical compatibility with the "parent version" is absolutely critical. You can add plenty more features, functions and commands, but all the things that are already there from QBasic should work absolutely identically. Legacy code from QB should be able to be copied and pasted in with two clicks and run flawlessly.

I'd love to be able to be one of the guys helping to contribute to that process, but unfortunately I don't know anything about C, so you really don't want me bumbling around in those source code files.
Logged
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #24 on: August 25, 2005, 12:46:19 PM »

BI files are called "header" files, they contain a bunch of function declarations that let you use libraries.  You simply do this:

#include "myheader.bi"

and it will load that file, and you can then use all the functions it contains.  Pretty simple, huh?

crt.bi contains functions from a library called "libc", or C's runtime library (C Runtime Library, "CRT").  FreeBASIC itself would not be possible without this library.  Two functions in the library are "printf" and "sprintf", which are used to print formatted text to a console, or copy formatted text to a string.

PRINT USING is printf's equivalent in QBasic.  It's not necessarily antiquated, it's just not well maintained.  According to the v1ctor in a separate thread, he just coded it by observation, and didn't spend a whole lot of time on it.  But it will probably be improved in the next version, some of the other authors are looking at it.

Printf, however, is exactly the same function as it is in C, it doesn't have to be rewritten or modified to work in FreeBASIC.  So by doing this:
Code:
#include "crt.bi"
Dim As Double x = 41014.5352512
PrintF "Output: %.2f", x
Sleep


It will format the number "x" out to two decimal places, printing this:  "Output: 41014.54"

There is a formatting reference here:
http://www.cplusplus.com/ref/cstdio/printf.html

It's meant for C++, but the formatting of the string is the same.  Of course, if you'd rather use PRINT USING it's still partially implemented, just not completely yet.
Logged
paleozord
Member
*
Posts: 57


« Reply #25 on: August 25, 2005, 02:50:41 PM »

Thanks, I guess including a file is indeed pretty simple after all. Out of curiosity do you have to distribute those files alongside the compiled EXE for it to work, or are they dynamically included in the compilation?

My problem unfortunately, is that I already have a pre-existing, huge QBasic program that I'm migrating (over 400k, which I consider large by QB standards) that has the PRINT USING command peppered all throughout it, and a simple search-and-replace with PRINTF won't work of course since the formatting is unique for each command, as well as the fact that I use different formatting in various places throughout the program.

I guess I'll just have to wait for the next version with the fix to come out.
Logged
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #26 on: August 25, 2005, 03:07:03 PM »

That you will.  There's an unstable release coming out soon, maybe there will be improvements to PRINT USING in that.  

It depends on the library used.  FreeBASIC includes "static libraries", like any compiler.  These static libraries can either include the library code itself, such as the FreeBASIC runtime library, or it can include code that links to a "dynamic library", contained in a .dll file, such as the Windows API, or SDL.

If you use a library that requires a DLL to be packaged, your program will pop a messagebox up saying that the required file could not be found, and then end.
Logged
paleozord
Member
*
Posts: 57


« Reply #27 on: August 25, 2005, 04:06:12 PM »

Bring on version 0.15 then I say....

I must also say that I object on rational, philosophical, religous, and purely visceral levels to any external files ever needing to be distributed with any EXE Program file. Final and Most Holy Compiled Programs must be completely self-sufficient, self-contained, and self-reliant, so that if the user was stuck on a desert island with nothing but that one EXE file on a floppy disk, an antique abacus, and a 1960's gas generator, he could run the darn thing just fine.

My programs do refer to external files during runtime, but those are just Random files that it checks for and tries to find at startup, and if it doesn't find them, it creates them from scratch. So it can never be accidetnally "stranded" without them, if someone copies the EXE but forgets the extras.
Logged
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #28 on: August 25, 2005, 06:18:49 PM »

...Well, in that case I would only use static libraries.
Logged
paleozord
Member
*
Posts: 57


« Reply #29 on: August 26, 2005, 07:35:33 PM »

Let me ask a really basic question. If I have a LIB file, like DSOCKQB.LIB, how do I link that to my program? Do I just use:

'$Include dsockqb.lib

? Or is there adifferent method?
Logged
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!