Main Menu

Old School

Started by johnno56, November 04, 2010, 05:13:25 PM

Previous topic - Next topic

johnno56

Greetings,

I have a bunch of older, non-structured, basic programs and would like to try and convert them to PB. Most of them are qbasic. I have tested the sample programs, that came with PB, and was impressed by the speed. Are there any tutorials, applications, videos etc in regards to file program conversion? I am sorry if my question(s) are too "noobish", but I have to start somewhere.

Regards

J
May your journey be free of incident.

Live long and prosper.

kevin

  I'm not aware of anything along those lines.   You could probably knock together quick and dirty search/replace translator to do some/most of the one to stuff.  But getting your hands dirty is inevitable I'm afraid.  

 One method I use when moving between dialects is creating a pseudo wrapper with a set of fixed functions.  Then port the wrapper to the various languages.  Then try and write my code within that framework.  You could do the same to aid porting between PB and QBASIC.  Roll a set of PB equivalents of qbasic functions them include them in your PB project.  Not everything will map over one to one mind you. But it will help speed up the process.


johnno56

Kevin,

Thankyou for replying.

I was afraid you were going to say that. I figured, if someone had done "the hard yards" first, I may not have to "get my hands dirty".

I am relatively new to PB and part of your response caused a, "say what?". I am not familiar with the term, "wrapper".

I have been "dabbling" in Basic since the very early 80's and some things that I have noticed are; that the newer basic's are more structured and have dropped line numbers etc. The graphics commands are different but not hard to understand. The mind boggles with the huge range of built-in functions!!

I hope you guys have a well equipped "newbies" section. Looks like I will have to "hit the books" and do a LOT of catching up.

Just to give you an idea on how great PB is; I use an old "clunker" of a laptop, when I cannot get on "my" main PC, for all my "basic" stuff. The laptop runs with Windows Me (Now my age is slipping) and PB runs fine. It's better than fine! It runs way faster than qbasic!! I would like to install PB on my main PC, but I run with Linux. Any members have success in running PB on Linux?

Anyway, back to the keyboard. These programs don't write themselves you know. (Or does PB have a function that I am not aware of?)

Regards

J

ps: Great program!!
May your journey be free of incident.

Live long and prosper.

kevin

QuoteI was afraid you were going to say that. I figured, if someone had done "the hard yards" first, I may not have to "get my hands dirty".

   Well,  I've messed around with a few translators myself, but never from Qbasic.    Getting a good result requires a lot of familiarity with the source and target.    It's possible to translate simple stuff, but really the more complex the program the less likely getting a working result will be.  Due to the compounding the differences between dialects.   


QuoteI am relatively new to PB and part of your response caused a, "say what?". I am not familiar with the term, "wrapper".

   It's creating a common user interface.   So you program using this interface (a set of functions) to abstract the underlying language as much as possible.  So when it comes time to move the segment of code, the changes needed are often very sutble.  Ie, syntax mainly.   The rest runs largely as expected.

   You can do the same with translating one language to another.  So as you scan through your Qbasic code, we convert any common functions your using into an eqivilent function in PB.   I generally use prefixes to show these.   

  For example, the math functions COS and SIN  are universal functions, but depending upon the lanugage they'll either use radian and angle inputs.  So if used Radians, to covert them to PB they need to be wrapper to reserve the original behavior of the routine.

  Ie.



Psub  QB_Cos(Radians#)
Degree#=RAdToDegree(RAdians#)
Result#=Cos(Degree#)
EndPsub Result#

Psub  QB_Sin(Radians#)
Degree#=RAdToDegree(RAdians#)
Result#=Sin(Degree#)
EndPsub Result#



   So when translating the a QB code fragment, we've replace any functions calls to COS() or SIN() with QB_COS() , QB_SIN().  Which can done with the a brute force search/replace is generally good enough.


Quote
  I have been "dabbling" in Basic since the very early 80's and some things that I have noticed are; that the newer basic's are more structured and have dropped line numbers etc. The graphics commands are different but not hard to understand. The mind boggles with the huge range of built-in functions!!

   Yeah, towards the later 80's line numbers started to vanish.  If you've got code that old, then it's still possible to convert, but some of the real spaghetti stuff isn't supported anymore, well at least not in PB.   

   When I was a kid doing computer science in the 80's, they drummed one entry and one exit design into us.    Which in retrospect can be really good exercise to program within.   So the routine has one entry point and one exit point.  No gotos, no exits.   Makes you think through the logic of every path through the routine.   


Quote
I hope you guys have a well equipped "newbies" section. Looks like I will have to "hit the books" and do a LOT of catching up.

Just to give you an idea on how great PB is; I use an old "clunker" of a laptop, when I cannot get on "my" main PC, for all my "basic" stuff. The laptop runs with Windows Me (Now my age is slipping) and PB runs fine. It's better than fine! It runs way faster than qbasic!! I would like to install PB on my main PC, but I run with Linux. Any members have success in running PB on Linux?

  I'm still running XP myself, don't see any benefits of moving up.    As for Linux, I've heard that it's possible (via wine). But haven't tried this myself.  So that may turn out to be fable.



johnno56

Kevin,

Thanks for all the advice. Looks like I'll have to "roll up the sleeves" and get stuck into it. I read a quote from a comp magazine, "Programming is an art. You have to stop sharpening your pencil and just start drawing...", or words to that effect.

In regards to Linux: I have tried using Wine to run PB, but unfortunately, PB looks like it will remain within Windows domain. The program installs just fine, but failed to execute for multiple reasons. It's a shame really, as Linux is my primary operating system.

As I continue, I am sure that I will pester you guys for more advice.

Many thanx

J
May your journey be free of incident.

Live long and prosper.