Skip to main content

[SOLVED] Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

I like Ian's solution. With a small modification it should not give a compilation error. vFieldName = "FLD_X" if($fieldname(vFieldName) != “”) …do sum else … v_sum = 0 endif


Author: Theo Neeskens (tneeskens@itblockz.nl)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

I simply would use a support table where initially move the data, with the respective keys, and then view and manage the same with all fields and the necessary functions.


Author: TheAleph (mail@gandg.it)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

Hi Ingo, part of the dITo Uniface Reflection concept (with the 2-phase compile) is: examine the repository for whatever is connected to the component and provide #defines in an included proc with the name of the component. #include DUR_COMP:<$componentname> in the components DEFINES trigger to use it anywhere in the second compile. It's totally up to you what you want to include there. Just a: #define FLD_X__A1 #define FLD_X__A2 or: what about $fieldinfo and check for error?


Author: ulrich-merkel (ulrichmerkel@web.de)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

You can do this at runtime using $fieldname if($fieldname(FLD_X) != "") ...do sum else ... v_sum = 0 endif   Iain


Author: Iain Sharp (i.sharp@pcisystems.co.uk)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

ulrich-merkel said what about $fieldinfo and check for error?

Hi Uli This may be work at runtime, but not at compile-time. A statment like "selectdb fct(field) ..." will result in an error if "field" is not accessible Ingo


Author: istiller (i2stiller@gmx.de)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

Then I recommend using the dITo  Uniface Reflection, as described in my post. It's a onetime effort to implement utility and menuitem.


Author: ulrich-merkel (ulrichmerkel@web.de)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

Iain Sharp said You can do this at runtime using $fieldname if($fieldname(FLD_X) != "") ...do sum else ... v_sum = 0 endif

Hi Iain No, you can't Laugh Uniface will throw an error on compile time. So you will never have an excutable component in which you can check $fieldname Ingo


Author: istiller (i2stiller@gmx.de)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

Yeah, I noticed, but this excuse for forum software now won't let me edit my previous post.... 


Author: Iain Sharp (i.sharp@pcisystems.co.uk)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

the following seems to do the job without compile errors, just stick it in an entry: entry check_compstamps #for ent = (USOURCE,UTPLFLD,UTPLGRP,UCTABLE,UCGROUP,UCFIELD,UAPPL,UFORM,UXGROUP,UXFIELD,UXREGS,UGREGS)    call check_compstamp("<ent>") #endfor #undefine ent end ; check_compstamps entry check_compstamp params    string entname : IN endparams    if ($fieldname("UCOMPSTAMP.%%entname%%%") != "")       selectdb max(UCOMPSTAMP) from "%%entname%%%" u_where(UTIMESTAMP > X_CSTAMP) to $1       putmess $concat(entname,":",$1)    else       putmess $concat(entname,": is not compiled")   endif end ; check_compstamp


Author: ulrich-merkel (ulrichmerkel@web.de)

&#091;SOLVED&#093; Conditional compile

Author: i2stiller@gmx.de (istiller)

Hi freaks Just a simple question Smile How to compile parts of code depending on the existence of fields? Background: Say, you have a few fields which are sometimes defined as database fields in a table, but sometimes not. Table A1     Table A2   Table B FLD_A11     FLD_A21   FLD_B1 FLD_X        FLD_X      FLD_B2 FLD_A12     FLD_A22   ... ... FLD_X is only present in A1 and A2 but not in B (and this schema goes on for a few 100 other tables) Now I got a proc-include for all the tables, in with (if exists) I want to calculate the sum of FLD_X selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM If FLD_X not in entity $entname, Uniface will not compile this statementFrown What I'm looking for is something like #ifexistfield FLD_X.<$entname>   selectdb sum(FLD_X) from <$entname> u_where (...) to v_SUM #else   v_SUM = 0 #endif Okay, there are workarounds like   Define FLD_X in all tables as non database field     (flooding tables with not necassary field)   Or define a precompiler constante FLD_X_exists    (have to be defined independent of the actual table definition)   Use "sql/data" instead                                      (one have to deal with field-formats, there is no u_where)   ... Any idea Or what's is the best way to handle thisLaugh Ingo

Okay there is a very simple solution selectdb fct(field) from "%%v_TABLE%%%" If UnifAce could not resolve the entity name at compiletime, there will be no error in the "field"-parameter Laugh Ingo


Author: istiller (i2stiller@gmx.de)