Chris Iverson
Junior Member
There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73
|
Post by Chris Iverson on Oct 11, 2007 18:39:34 GMT -5
I can't figure out what I'm doing wrong, and I'm fairly sure it shouldn't crash RB. I've got this very rudimentary code to use as a module(not permanently):
Print "Login module running."
Function Login(username$, password$) Print "Logging in..." open "user" for input as #file line input #file, uname$ line input #file, pass$ close #file Login = 1 If username$ <> uname$ or password$ <> pass$ then Login = 0 End Function
Function Change(username$, password$) Print "Changing password..." open "user" for output as #file print #file, username$ print #file, password$ close #file End Function
I try to run it with this code:
run "login", #login
a = #login Change("Iam", "auser") render #login
And it crashes with the error 'Unhandled Exception: Subscript out of Range' or 'unhandled exception' and something to do with #x.
EDIT: I found the error, it's in the Login sub, OPEN needs to have a full path, e.g. "C:\rbp\login_project\user". Still don't think this should crash RB.
|
|
|
Post by carlgundel on Oct 11, 2007 19:17:52 GMT -5
I can't figure out what I'm doing wrong, and I'm fairly sure it shouldn't crash RB. I've got this very rudimentary code to use as a module(not permanently): Print "Login module running."
Function Login(username$, password$) Print "Logging in..." open "user" for input as #file line input #file, uname$ line input #file, pass$ close #file Login = 1 If username$ <> uname$ or password$ <> pass$ then Login = 0 End Function
Function Change(username$, password$) Print "Changing password..." open "user" for output as #file print #file, username$ print #file, password$ close #file End Function I try to run it with this code: run "login", #login
a = #login Change("Iam", "auser") render #login And it crashes with the error 'Unhandled Exception: Subscript out of Range' or 'unhandled exception' and something to do with #x. EDIT: I found the error, it's in the Login sub, OPEN needs to have a full path, e.g. "C:\rbp\login_project\user". Still don't think this should crash RB. You're right. It shouldn't crash, but that's what beta testing is for. Thanks! -Carl
|
|
|
Post by carlgundel on Oct 12, 2007 11:14:01 GMT -5
EDIT: I found the error, it's in the Login sub, OPEN needs to have a full path, e.g. "C:\rbp\login_project\user". Still don't think this should crash RB. The full path is not required and in fact if works fine in general. However perhaps it is related to the fact that you are running an embedded component. Right now I'm working on documentation for RB, but maybe later today I'll take a break and try to track that down. -Carl
|
|
Chris Iverson
Junior Member
There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73
|
Post by Chris Iverson on Oct 12, 2007 15:32:16 GMT -5
Yes, I did notice that it worked fine when I just put the open command in a file alone, and not as a module. It also appears that if a file doesn't exist when you OPEN it for INPUT while the command is in a module, RB crashes.
|
|
|
Post by carlgundel on Oct 12, 2007 15:57:48 GMT -5
Yes, I did notice that it worked fine when I just put the open command in a file alone, and not as a module. It also appears that if a file doesn't exist when you OPEN it for INPUT while the command is in a module, RB crashes. When you say it crashes, do you mean the server crashes and you have to start it back up again, or do you mean that your program stops with an error indication in the browser? Opening a non-existent file should cause a runtime exception, not a hard crash of the server. -Carl
|
|
Chris Iverson
Junior Member
There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73
|
Post by Chris Iverson on Oct 12, 2007 16:43:23 GMT -5
It's a hard crash; I think it says 'unhandled exception: subscript out of range' or something similar. Not the webpage, it's a notice that RB gives just before it goes PKEEWWWW.
Edit: It's 'Unhandled exception: Subscript out of bounds', so yeah, same thing. I think >_>
|
|
Chris Iverson
Junior Member
There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73
|
Post by Chris Iverson on Oct 18, 2007 16:29:12 GMT -5
I've noticed that if you allow the program execution timeout to expire, the error goes away without RB crashing. I don't know if this has any repercussions or anything.
|
|
|
Post by turbov21 on Oct 21, 2007 16:18:53 GMT -5
Why is "Change" a function when it doesn't return a value?
|
|
Chris Iverson
Junior Member
There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73
|
Post by Chris Iverson on Oct 21, 2007 19:31:13 GMT -5
For two reasons: 1. Because I don't think you can call subs in RB modules yet. At least, you couldn't in Beta 3. I forgot to check with beta 4.
And 2: Personal preference. For some reason, I have always avoided making my stuff subroutines. Although I still do in a lot of programs, I always gravitate toward functions. Don't ask me why.
EDIT: Confirmed, you can't called subs in a module. Only functions.
|
|
|
Post by Jerry Muelver on Oct 22, 2007 4:51:22 GMT -5
Chris, you could have your no-returns functions return at least a success indicator -- 0 or 1. The you could say,
if Login(uname$,pword$) then... else...
for a more logically flowing program narration.
|
|
Chris Iverson
Junior Member
There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73
|
Post by Chris Iverson on Oct 30, 2007 11:59:51 GMT -5
Login does do that, I forgot
|
|