basicprogramming.org


Welcome, Guest. Please login or register.
Did you miss your activation email?
Forum time; Jul 31. 2010, 04:21
Home Help Search Calendar Login Register
News: Have you got suggestions for BasicProgramming.org? Let's hear them!
Interested in creating your own programming language? Check out the QDepartment group!

+  BASIC programming forum
|-+  Basic Coding
| |-+  Other programming languages.
| | |-+  extensive qbasic -> python reference
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Reply Print
Author Topic: extensive qbasic -> python reference  (Read 159 times)
menn
Hero Member
*****
Offline Offline

Posts: 571


« on: Sep 26. 2009, 09:13 » Reply with quote

qbasic -> python reference
2009 mennonite


i, the copyright holder of this work, hereby release it into the public domain. this applies worldwide.

in case this is not legally possible:
i grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

qbasic python
print|print
print "";|print "",
color / locate / cls (text mode)|like in many other scripting languages, and yabasic, you'll need ansi codes or the curses lib for this
chr$()|chr()
q$="a"+"z"|q="a"+"z"
abs()|abs()
int()|int()
mod|%
val()|float()
rnd|random.random()
sqr()|math.sqrt()
sin()|math.sin()
cos()|math.cos()
tan()|math.tan()
ucase$(q$)|q.upper()
lcase$(q$)|q.lower()
asc()|ord()
data lines, i, dislike|lists=['are','fantastic','things']
inkey$|no equivalent in text mode
input$(1)|getch() in curses lib
line input|raw_input
instr(l,f)|l.find(f)
space$(n)|chr(32)*n
left$(q$,n)|q[:n]
right$(q$,n)|q[-n:]
mid$(q$,n,1)|q[n-1]
mid$(q$,n,l)|q[n-1:n-1+l]
str$()|str()
ltrim$()|string.lstrip()
rtrim$()|string.rstrip()
if cond then|if cond:
if then / elseif then / else / end if|if: / elif: / else:
select case var / case is / case else / end select|if var: / elif var: / else:
do while cond... loop|while cond:
do... loop until cond|while not cond
for n = n1 to n2 step floatvar|for n in range(n1, n2+1, intvar):
open f$ for input as #1|num1=open(f)
open f$ for append as #1|num1=open(f,'a')
open f$ for output as #1|num1=open(f,'w')
close #1|num1.close()
print #1, q$|num1.write(q)
do while not eof(1): line input #1, q$: loop|for line in num1: q=line
on error goto linenumber
command
|try: command
except:
if err = 2 then:|except SyntaxError:
error 2|raise SyntaxError('sharif don\'t like it')
resume next|except: pass
timer|use int(time.strftime(f)) to get ("%H"*60+"%M")*60+"%S"
time$|time.strftime("%H%M%S")
sleep seconds|time.sleep(seconds.dec)
shell q$ 'silent|x=os.system(q)
shell q$ 'echo|x=os.popen(q)
for line in x: print line,
command$|string.join(sys.argv," ")
Report to moderator   Logged

an "all purpose" language calls for- as much as can possibly be reasonable- an "all purpose" forum. the worst thing happening to modern basic? too many pointless rules and painting everything into corners. most modern basic forums are like that too.
gp1628
Staff Member
Full Member
*
Offline Offline

Posts: 184



« Reply #1 on: Sep 26. 2009, 11:25 » Reply with quote

Way Cool! Thanks for that.
Report to moderator   Logged
menn
Hero Member
*****
Offline Offline

Posts: 571


« Reply #2 on: Sep 26. 2009, 12:01 » Reply with quote

certainly! i'll probably release my qb.color qb.locate and qb.cls functions (to the public domain) here too, so no one has to figure out the ansi codes. they should be useful in yabasic too (i was a fan of yabasic long before python.)

the color codes are easy enough to remember, but locate and cls are arbitrary enough that you'd have to use them several times before you remembered. in curses there's no need for special qb.functions, all the codes are easy enough to remember with practice (there are no number codes, it's stuff like curses.COLOR_BLUE, etc... you can see them in other examples on this subforum.)
« Last Edit: Sep 26. 2009, 12:08 by menn » Report to moderator   Logged

an "all purpose" language calls for- as much as can possibly be reasonable- an "all purpose" forum. the worst thing happening to modern basic? too many pointless rules and painting everything into corners. most modern basic forums are like that too.
E.K.Virtanen
Blah
Hero Member
*****
Offline Offline

Posts: 2441



WWW
« Reply #3 on: Sep 26. 2009, 14:11 » Reply with quote

Neat work menn.
Since you are now motivated for this kind of things, then how about something similar with example codes? Wink

Would be neat add in bp.org contents  Roll Eyes

I can here also reveal that, new interview is under work, but it prolly takes like a month before it's done, since person who im interviewing is currently on business trip. But that is a secret still...errr...YOU SHALL NOT REMEMBER THIS MESSAGE - YOU SHALL NOT REMEMBER THIS MESSAGE - YOU SHALL NOT...who's im fooling here anyway.
Report to moderator   Logged

menn
Hero Member
*****
Offline Offline

Posts: 571


« Reply #4 on: Sep 26. 2009, 19:20 » Reply with quote

Neat work menn.
Since you are now motivated for this kind of things, then how about something similar with example codes? Wink

Would be neat add in bp.org contents  Roll Eyes

it's going to be a while before i do "mennonite's pretty good intro to python," today i imported turtle and tried graphics for the first time (but it uses tkinter, the lib that idle uses, which is not included or configured in my favorite distro...)

but so long as you're enjoying it, i could probably do something halfway between this and mpgitp... also i'm running a "new" (old) version of python in dosbox with cwsdpmi, http://caddit.net/pythond not sure if it's performing really great... 24mb zip to install! (plus cwsdpmi not included) maybe i should try it with cwsdpr0... dos! it's been a while...
Report to moderator   Logged

an "all purpose" language calls for- as much as can possibly be reasonable- an "all purpose" forum. the worst thing happening to modern basic? too many pointless rules and painting everything into corners. most modern basic forums are like that too.
Pages: [1] Go Up Reply Print 
« previous next »
Jump to:  
Atom RDF RSS 0.91 RSS 2.0


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!