SC Making Default Value Decisions - This is wrong!

While it was my mistake in setting a field value and accidentally mis-spelling it in one of the events to set it to a value, I found generated code within scriptcase that will automatically set a default value based on the field type. This is wrong!

I figured this out because I had set a default value in the table column in MySQL. The default value was never set on insert to the value I assigned to the column (and yes I expected it to use the default because I wasn’t passing a value by accident). I do not expect an application to set a default value behind the scenes. While I understand there are ways to do it in the SC field definition, SC should not assume that it should default a value based on data type.

Here is the code I found:
[SIZE=12px][COLOR=#007700][COLOR=#000000]4485| if ($this->payment_complete == “”)
4486| {
4487| $this->payment_complete = 0;
4488| $this->sc_force_zero[] = ‘payment_complete’;

Here is other code I found that sets a field to a default value:[/COLOR][/COLOR][/SIZE]

[SIZE=12px][COLOR=#007700][COLOR=#000000]4466| if ($this->idregsitry == “”)
4467| {
4468| $this->idregsitry = 0;
4469| }
4470| if ($this->vessel_loa == “”)
4471| {
4472| $this->vessel_loa = 0;
4473| $this->sc_force_zero[] = ‘vessel_loa’;
4474| }
4475| if ($this->vessel_beam == “”)
4476| {
4477| $this->vessel_beam = 0;
4478| $this->sc_force_zero[] = ‘vessel_beam’;
4479| }
4480| if ($this->vessel_draft == “”)
4481| {
4482| $this->vessel_draft = 0;
4483| $this->sc_force_zero[] = ‘vessel_draft’;
4484| }

No application should set a default if none is coded in the field definition within the generated application. This is a bad assumption on SC’s part. This needs to be changed![/COLOR][/COLOR][/SIZE] [HR][/HR]

Hello pkrawetzky:

I understand your problem but… fields initialization is one of the features we all want into a RAD tool, most memory overheaps, insertion errors and buffer overflows come from NONINITIALIZED VARIABLES.

you can always set the values you would like in scriptcase using scriptcase GUI itself or using code in the several events of an applications.


You are correct in that the USER should make these choices and NOT SC. That is my point. SC should NOT be making default decisions.

ok Man:

Firstly SC initializes to default null equivalent values… secondly… my point is “if the user is too lazy to initialize a variable SC is doing that work for him which btw is the right thing to do”. and lastly… as I said… if you are not a lazy user then you will have no problem initializating your variables and overwriting SC default initialization which ultimately means… THERE IS NO PROBLEM HERE.


What you don’t understand (and I take offense to your rude comment) is that some fields defaults are in a database which is perfectly legitimate code practices. With SC setting the default, the database default will never get set if the application should be sending it a null value. No tool should set defaults, it should be up to (what you are referring to as a lazy coder) the coder to make that decision.

Ok if I offended you I give you an apology since is not my intention. And I understand what you say. but when you are talking about DEFAULTS in your database… that means that whenever you insert a NULL value into the field… the DB is going to set default value you have preset… again NO PROBLEM THERE. my reference to a lazy user… and I stick to it… is that the user can choose to initialize the variables… you can do it… SC gives you the means and the tools to do so… but… what happens if you dont do it?.. then SC has to do that for you (to ensure the best practice).

If you are not lazy you will initialize w/e you need to initialize, if you don’t SC will do it for you then. I would be way more worried about SC not destroying variables properly which BTW i think it doesn’t which demands all variables to be set to null values and then freed from memory.

So again… if you ask me and… in some way you are since you are posting in a forum where I have participation… you sayin “SC is initializing variables and thats WRONG” is a mistake.


No other RAD tool I’ve used does this. What happens is a database error will occur stating the value must not be null and allows the developer to determine where the best place is to set a default. So I guess I’m at a stalemate with you on this so it will be my last post on the subject. Frankly there are other pressing problems with SC that need to be fixed so maybe we should concentrate on that.

more than agreed