because when I run the program it should tell me if it was a Sunday or a Monday or a Tuesday any day after the if statement why shouldn't it be executed?
i know it's old code but i am using this to learn and understand better
Title: Re: gwbasic's if statement doesn't work on qb64
Post by: Cobalt on January 04, 2021, 07:53:23 pm
The only thing to learn from that is how NOT to do things like that anymore.
Title: Re: gwbasic's if statement doesn't work on qb64
Post by: STxAxTIC on January 04, 2021, 07:55:50 pm
I'm with Cobalt. This code should just be "looked at", not "read".
Title: Re: gwbasic's if statement doesn't work on qb64
Post by: Pete on January 04, 2021, 08:20:59 pm
Use SELECT CASE, instead of IF/THEN, as in: SELECT CASE of dynamite and blow that code to hell.
By running the program, we generate a B value for the day, and our calculation ends up returning negative values to us. (For 1/1/2021, the value ends up telling us that our day is the -9th day, which is completely meaningless.) Now, what's glitched here, I have no clue. Perhaps, it's like STx has suggested and one of the FUNCTIONS is wrong, or perhaps it's something else completely. If you've translated this code from some original QB45 source, kindly share the source so we can compare the two versions, otherwise, I'm afraid, about all you can get here is some basic confirmation: "Yep, it's buggy."
The IF statements work fine; but there's something in the math that simply doesn't compute properly, as written.
Title: Re: gwbasic's if statement doesn't work on qb64
Post by: Adrian on January 05, 2021, 03:06:11 am
ok, i think the problem was function fnb(A). changing it to fnb=INT(A/7) seems to work.
Title: Re: gwbasic's if statement doesn't work on qb64
Post by: Richard Frost on January 05, 2021, 05:42:16 am
Aye, that code isn't worth trying to figure out. The only purpose such code serves is to show a person how NOT to program. To "learn" from that code is like learning all about toaster ovens when one wants to learn how to fix a car. Study the code on these forums. It's all far better stuff.
Do look up the LET command in the Wiki here. It's hilarious. And true.
Title: Re: gwbasic's if statement doesn't work on qb64
Post by: _vince on January 05, 2021, 10:17:04 am
line 170 was properly translated to the other function.
Title: Re: gwbasic's if statement doesn't work on qb64
Post by: Kiara87 on January 05, 2021, 03:31:25 pm
thank you all for replying the problem was as adrian and bplus says here was the reason that I don't notice the day of variable b FUNCTION fnb (A) fnb = INT(A / 7) END FUNCTION