0

loop failure

I have a data quality issue and built a simple block of code to set some choice and idx values.  The code works fine on a current selected record.  However enclose it in a for or while loop and it fails.  What have I got wrong?  Needs to loop there are 11000 + records in the table.  I'm suree there must be batter ways but the loop failure has me puzzled.  Current ninox version is being used.

 

Code without the loop

var wtxt := " ";
var q := 0;
var counter := 0;
var cstop := count(select IR_SNow_Apps_to_OSIs) + 1;
var rec := record(IR_SNow_Apps_to_OSIs,0);
q := index(this.app_id_name, "-");
if q > 0 then
IdxTC1 := q;
TypeChoice1 := 1
else
wtxt := app_id_name;
let r := index(wtxt, " ");
if r > 0 then
IdxTC1 := r;
TypeChoice1 := 2
else
IdxTC1 := 0;
TypeChoice1 := 3
end
end;
wtxt := substr(app_id_name, IdxTC1 + 1, length(app_id_name));
let p := index(wtxt, "-");
if p > 0 then
idxTC2 := p;
TypeChoice2 := 1
else
let r := index(wtxt, " ");
if r > 0 then
idxTC2 := r;
TypeChoice2 := 2
else
idxTC2 := 0;
TypeChoice2 := 3
end
end

 

Code block with loop

 

var wtxt := " ";
var q := 0;
var counter := 0;
var cstop := count(select IR_SNow_Apps_to_OSIs) + 1;
var rec := record(IR_SNow_Apps_to_OSIs,0);
while counter <= cstop do
rec := record(IR_SNow_Apps_to_OSIs,counter);
q := index(this.app_id_name, "-");
if q > 0 then
IdxTC1 := q;
TypeChoice1 := 1
else
wtxt := app_id_name;
let r := index(wtxt, " ");
if r > 0 then
IdxTC1 := r;
TypeChoice1 := 2
else
IdxTC1 := 0;
TypeChoice1 := 3
end
end;
wtxt := substr(app_id_name, IdxTC1 + 1, length(app_id_name));
let p := index(wtxt, "-");
if p > 0 then
idxTC2 := p;
TypeChoice2 := 1
else
let r := index(wtxt, " ");
if r > 0 then
idxTC2 := r;
TypeChoice2 := 2
else
idxTC2 := 0;
TypeChoice2 := 3
end
end
end

3 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    Phillip, You never increment "counter" so it looks like you have an infinite loop.

    • phillipsloper_mecom
    • 4 yrs ago
    • Reported - view

    feeling very silly, thank you !

    • Sean
    • 4 yrs ago
    • Reported - view

    I am somewhat experienced on the topic 😬