Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Am I the one?: require()

Status
Not open for further replies.

naq2

Programmer
Aug 3, 2004
74
FR
I have some trouble when using require(): sometimes it works, sometimes it doesn't. Have you faced the same problem?

I have a script that does some requires (12) inside the code (not at the beginning).

When I access the script via my favorite browser (Firefox), it can:
[ul][li]execute 1 require() and crash[/li]
[li]execute no require() at all and crash[/li]
[li]execute 8 require() and crash[/li]
[li]execute all the require() and do not crash! :)[/li][/ul]
(I'm skipping all the intermediate values!)

Everytime I reload the page, I get a different value.

Do you know how can I face this? coz for now, my script is not very reliable!

Thanks a lot if you can help! I think I really have all the strange bugs... just for me!
 
When requiring scripts, always end the script with the value 1, that might make a difference.

I sincerely doubt if you're the one, Jimmy Bakker thought he was the one and the IRS convinced him otherwise

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
snif! ... so I'm not the one.

but my scripts already ends with return 1 ;

...so there is no way on improving the reliabilty of a script using require?
 
Other than debugging, I'd say no

12 scripts is rather a lot, how many variable assignments are common? - how many scripts might one variable be assigned

You might be best advised to conjoin your scripts into one or two (with a config file)

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
the scripts are very very short. 3 lignes maximums.

And their are (and have to be) imported on the fly... That's why I'm doing like this.
But the problem don't seem to come from there coz it crashes also after the first one sometimes.

I'm desesperate! snif! :)
 
Quit whinging

Why do you need a three line script?

--Paul


It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Coz for the moment it's 3 line and it might change in time.

I'm parsing a HTML file and throwing each tag to a specific function.
These functions are interchangeable and a managed by an XML file.

I find the tag ->
I check if I know how to process this tag (in the XML file) ->
I check if it is an opening tag or not ->
I check if opening this tag means closing other tags that are open ->
I ask a specific function (that is outside, in a file that I have to require(); the URL beeing in the XML file) to process this tag ->
I go to the next tag.

That is what I'm doing... and I have a reliability problem with the require() that I shouldn't have.
I just hope I can fix it!
 
Why not turn all of your required scripts into Sub-Routines in the main script? That way, the calls will still be dynamic and you can better manage the code itself.

- Rieekan
 
What I was about to say, he says already ...
--Paul
 
Sorry for taking your thunder Paul. I'll restrain next time. [smile]

- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top