0

Within switch do structure, is there a determined structure of how to define variables?

I am only just learning to code in Ninox and I was busting in my head trying to figure out why I kept getting an error message, and it turns out it had to do with the sequence in which I determined the variables or values of pre-existing variables. More precisely, block 1 below did not return an error message and block 2 returned the message "Symbol expected: case, default, end in line 7, column 24"

But the only difference between the two block variants is the fact that in block 1, new variables are defined via the "let" function and subsequently the pre-existing bdScript is assigned a new value, while in block 2, it's the other way round...

Can anybody explain, I could not find anything on the internet. Is there a specific determined sequence that needs to be fulfilled? Or am I missing something completely else here?

Block 1 (no error message)

let bdScript := "";
switch ((select Adressbook).birthdaycheck > 0) do

case true:

let xMaxId := max((select Adressbook).Nr);
let xDone := "No";
let xCounter := 1;
bdScript := "Some candidates have a birthday
Concerns candidate(s):
";

while xCounter < xMaxId do
let i:= (select Adressbook where Nr = xCounter).birthdaycheck;
let j:= (select Adressbook where Nr = xCounter).FirstName;
let k:= (select Adressbook where Nr = xCounter).Surname;

if i = 1 then
bdScript := bdScript + j + k + "
";
xCounter := xCounter + 1
else xCounter := xCounter + 1 end;
end
end;

alert(bdScript)

 

 Block 2 ("Symbol expected: case, default, end in line 7, column 24")

 

let bdScript := "";
switch ((select Adressbook).birthdaycheck > 0) do

case true:

bdScript := "Some candidates have a birthday
Concerns candidate(s):
";

let xMaxId := max((select Adressbook).Nr);
let xDone := "No";
let xCounter := 1;

while xCounter < xMaxId do
let i:= (select Adressbook where Nr = xCounter).birthdaycheck;
let j:= (select Adressbook where Nr = xCounter).FirstName;
let k:= (select Adressbook where Nr = xCounter).Surname;

if i = 1 then
bdScript := bdScript + j + k + "
";
xCounter := xCounter + 1
else xCounter := xCounter + 1 end;
end
end;

alert(bdScript)

 


Sorry for being a noob but I'm just at the beginning of my huge endeavour here :)

1 reply

null
    • Ruben
    • 3 yrs ago
    • Reported - view

    Hello,

    sorry about the mess, but it turns out something entirely different must have caused this, that I can't explain yet.

    Anyway the code is now fixed and works and I don't get this effect anymore when switching the sequence of commands... please ignore or delete this post. 

Content aside

  • Status Answered
  • 3 yrs agoLast active
  • 1Replies
  • 398Views