You can have various logics, in different positions and syntax of the code, run according to your wishes using the value of this Boolean. I will explain 3 possibilities of operation:
(1) To create another variable, within struct
Within fields
, just use a simple if
to create the logic. It is important to understand that since the variable [pagouMulta]
is already a Boolean, you can write the condition of if
either as if([pagouMulta] == true)
or simply as if([pagouMulta])
, and creation of new field
would be:
struct[STR_Dados_dos_Inadimplentes] {
fields {
+[pagouMulta]: Boolean {
name = "Pagou multa"
request = "A multa foi paga?"
},
if([pagouMulta]) {
+[valorMulta]: Integer {
name = "Valor da Multa"
request = "Qual foi o valor da multa paga?"
}
}
}
},
Then the [valorMulta]
field will only exist, and will be asked if the user response is true
to [pagouMulta]
.
(2) For operation of some logic, within struct
By putting an operation logic inside struct
, it executes with priority, so a value of this struct
changes, and is valid for all objects instantiated for this struct
, and for that, create this logic within loaders
, as below:
struct[STR_Dados_dos_Inadimplentes] {
fields {
+[pagouMulta]: Boolean {
name = "Pagou multa"
request = "A multa foi paga?"
}
}
loaders {
if([pagouMulta]) {
//Operação específica que queira realizar, como por exemplo:
print "A multa foi paga"
}
}
},
(3) For operation of some logic, within
operations
of
head
,
body
or
extra
To use this variable within operations
, it can only be done when using a variable instantiated as STR_Dados_dos_Inadimplentes
. So let's say we create a variable with +<inadimplente>: STR_Dados_dos_Inadimplentes
, and we want to do an operation within operations
of head
, so we can do:
head {
operations {
if(<inadimplente.pagouMulta>){
// Operação que queira executar, como por exemplo, usar uma branch específica para multa paga
use branch[BRC_Multa_Paga]
}
}
}
In your example, specifically, you created the |inadimplentes|
vector, so to do the operation, we have two ways:
1. Select a specific vector element, using the Vector index to select a specific object, such as |inadimplentes{0}|
for the first element, |inadimplentes{1}|
for the second, and so on, and only replace if(<inadimplente.pagouMulta>)
with if(|inadimplentes{0}.pagouMulta|)
Home
2. Use a foreach
to do the operation on all Vector elements, such as:
head {
operations {
foreach(<inadimplente> IN |inadimplentes|) {
if (<inadimplente.pagouMulta>) where (separator = "%f1, %s2, %p2 e %l2.") {
// Operação que queira executar, como por exemplo, imprimir os dados do inadimplente
print <inadimplente>
}
}
}
}