Qbasicnews.com

Full Version: Windows to DOS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone,

This might be a more advanced question but I have made a password script which uses windows for getting access and than i just made a plain registration script.

The problem I need solving is that once the right password is entered that they can start the registration!

My scripts runs like this: I enter the correct password and than use the goto code but windows wont switch to dos.

Password code:

Code:
nomainwin
enter$ = chr$(_VK_RETURN) : backspace$ = chr$(_VK_BACK)
bs = 2 '

WindowWidth = 285 : WindowHeight= 130
'center the window
UpperLeftX = (DisplayWidth-WindowWidth)/2
UpperLeftY = (DisplayHeight-WindowHeight)/2

'graphicbox is used to capture key input
graphicbox #pass.gb, 0,0,0,0
textbox #pass.tb, 1,20,275,25
'ok button optional
button #pass.default, "Ok", [ok],UL 100,60,70,25
open "Enter Password" for window as #pass
print #pass, "trapclose [quitpass]"
print #pass, "font courier_new 10 bold"
print #pass.gb, "setfocus"
print #pass.gb, "when characterInput [letter]"
timer 400, [t]
wait

[t]
'if enter = 1 the enter key was pressed
if enter = 1 then timer 0 : goto [ok]
print #pass.gb, "setfocus"
wait

[letter]
timer 0
key$ = Inkey$ : key$ = left$(Inkey$, 2) : vkey$ = right$(key$,1)
if vkey$ <> enter$ and vkey$ <> backspace$ then
b$ = b$ + key$ : b = len(b$) : fill$ = ""
for x = 1 to b:fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
end if
if vkey$ = enter$ then enter = 1
if vkey$ = backspace$ and bs = 2 then
b = len(b$) : b=b-1 : b$ = left$(b$,b) : fill$ = ""
for x = 1 to b : fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
bs = bs +1: if bs = 3 then bs = 1 else if bs = 1 then bs = 2
end if : timer 400, [t]
wait

[quitpass]
timer 0
close #pass
end

[ok]
timer 0
if b$ = "hello" then 'password is "ok"
'do events for correct password
notice " " + chr$(13) + "Correct password" : print #pass.tb, ""
print #pass.gb, "setfocus" : b$ = ""
enter = 0 'leave timer off if opening a new window "timer 0"
timer 400, [t]
else
'do events for wrong password
notice " " + chr$(13) + "Wrong Password!" : print #pass.tb, ""
print #pass.gb, "setfocus" : b$ = "" : enter = 0 : timer 400, [t]
end if
wait

Registration code:

Code:
PRINT "Welcome to the registration forms!"
PRINT "Please complete the fields marked with an '*' and the normal fields are optional."
PRINT "Here we go..."
PRINT "Full Name? *"
PRINT "Example: Ely Edgard Daniel Raeds"
INPUT N$
PRINT " "
PRINT "Please choose a password *"
INPUT P$
PRINT " "
PRINT "Please re-enter your password *"
INPUT Q$
PRINT " "
PRINT "Please enter your e-mail address *"
PRINT "Example: yourname@yourdomain.com"
INPUT E$
PRINT " "
PRINT "Please re-enter your e-mail address *"
INPUT R$
PRINT " "
PRINT "Share e-mail address?"
INPUT M$
PRINT " "
PRINT "Your location?"
PRINT "Example: Belgium"
INPUT L$
PRINT " "
PRINT "Your interests?"
INPUT I$
PRINT " "
PRINT " "
PRINT "Thank you for registrating with us. We hope you will have a pleasant stay!"
PRINT " "
PRINT "Disclaimer:"
PRINT "Your e-mail will not be given/sold to any companies/users unless you gave us permission."
if you use a graphics screen mode, the program will automatically go 'full-screen" DOS mode.

for example:

Code:
SCREEN 0   'will stay in windows mode

INPUT password$

PRINT password$
PRINT
PRINT "Going to DOS mode"

SCREEN 11   'now computer goes to "DOS-MODE"

PRINT
PRINT password$
END

I hope this helps
you can't call another file with goto, as i remember from my vb experience. try compiling your qbasic program, and calling it from vb with "shell".
Quote:if you use a graphics screen mode, the program will automatically go 'full-screen" DOS mode.

for example:

Code:
SCREEN 0   'will stay in windows mode

INPUT password$

PRINT password$
PRINT
PRINT "Going to DOS mode"

SCREEN 11   'now computer goes to "DOS-MODE"

PRINT
PRINT password$
END

I hope this helps

Interesting! Thanks and I will give it a try! 8)
Sorry, but code was a bit to advanced for me, I am only a total n00b to this and the code didn't seem to work out, but I fought my way through and I made the following code.

Problem occuring now: I do get in the text area [DOS] and now the inputs dont' work! Can some on of you get libertybasic and copy paste the code and try to find how I can make the code work with that?

It's just the inputs that don't work! :evil:

Code:
nomainwin
enter$ = chr$(_VK_RETURN) : backspace$ = chr$(_VK_BACK)
bs = 2 '

WindowWidth = 285 : WindowHeight= 130
'center the window
UpperLeftX = (DisplayWidth-WindowWidth)/2
UpperLeftY = (DisplayHeight-WindowHeight)/2

'graphicbox is used to capture key input
graphicbox #pass.gb, 0,0,0,0
textbox #pass.tb, 1,20,275,25
'ok button optional
button #pass.default, "Ok", [ok],UL 100,60,70,25
open "Enter Password" for window as #pass
print #pass, "trapclose [quitpass]"
print #pass, "font courier_new 10 bold"
print #pass.gb, "setfocus"
print #pass.gb, "when characterInput [letter]"
timer 400, [t]
wait

[t]
'if enter = 1 the enter key was pressed
if enter = 1 then timer 0 : goto [ok]
print #pass.gb, "setfocus"
wait

[letter]
timer 0
key$ = Inkey$ : key$ = left$(Inkey$, 2) : vkey$ = right$(key$,1)
if vkey$ <> enter$ and vkey$ <> backspace$ then
b$ = b$ + key$ : b = len(b$) : fill$ = ""
for x = 1 to b:fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
end if
if vkey$ = enter$ then enter = 1
if vkey$ = backspace$ and bs = 2 then
b = len(b$) : b=b-1 : b$ = left$(b$,b) : fill$ = ""
for x = 1 to b : fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
bs = bs +1: if bs = 3 then bs = 1 else if bs = 1 then bs = 2
end if : timer 400, [t]
wait

[quitpass]
timer 0
close #pass
end

[ok]
timer 0
if b$ <> "hello" then 'password is "ok"
'do events for correct password
'notice " " + chr$(13) + "Correct password" : print #pass.tb, ""
'print #pass.gb, "setfocus" : b$ = ""
'enter = 0 'leave timer off if opening a new window "timer 0"
'timer 400, [t]
'else
'do events for wrong password
notice " " + chr$(13) + "Wrong Password!" : print #pass.tb, ""
print #pass.gb, "setfocus" : b$ = "" : enter = 0 : timer 400, [t]
else
timer 0
close #pass
goto [registrationform]
end if
wait
'------------------------------------------------------------
[registrationform]
'open a text window

open "Example" for text as #1  ' Make a DOS screen
print #1, "!trapclose [quit]"
PRINT #1, "Welcome to the registration forms!"
PRINT #1, "Please complete the fields marked with an '*' and the normal fields are optional."
PRINT #1, "Here we go..."
PRINT #1, "Full Name? *"
PRINT #1, "Example: Ely Edgard Daniel Raeds"
'INPUT #1, N$
PRINT #1, ""
PRINT #1, "Please choose a password *"
'INPUT #1, P$
PRINT #1, ""
PRINT #1, "Please re-enter your password *"
'INPUT #1, Q$
PRINT #1, ""
PRINT #1, "Please enter your e-mail address *"
PRINT #1, "Example: yourname@yourdomain.com"
'INPUT #1, E$
PRINT #1, ""
PRINT #1, "Please re-enter your e-mail address *"
'INPUT #1, R$
PRINT #1, ""
PRINT #1, "Share e-mail address?"
'INPUT #1, M$
PRINT #1, ""
PRINT #1, "Your location?"
PRINT #1, "Example: Belgium"
INPUT #1, L$
PRINT #1, ""
PRINT #1, "Your interests?"
'INPUT #1, I$
PRINT #1, ""
PRINT #1, ""
PRINT #1, "Thank you for registrating with us. We hope you will have a pleasant stay!"
PRINT #1, ""
PRINT #1, "Disclaimer:"
PRINT #1, "Your e-mail will not be given/sold to any companies/users unless you gave us permission."
PRINT #1, "Press any key to continue..."
'INPUT #1, D$
wait
[quit]
close #1 'close DOS screen
end
No one can solve?
Well, I don't have liberty basic Sad
I might try and use the program you are using... Where can i donwload it?? :lol:
Aaack! Make Liberty Basic go away! Bad Liberty Basic! :o

:lol: