Buildops
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard. :D
Initialize the variable in the "before" code, and use it in the "per record" section. If you must, create a static variable. If that term is unfamiliar, enrol in a class to learn some C.
Initialize the variable in the "before" code, and use it in the "per record" section. If you must, create a static variable. If that term is unfamiliar, enrol in a class to learn some C.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
I tried that. I have defined the following in Definitions :
#include<stdio.h>
#include<iostream.h>
int x ;
static int y ;
In Pre-Loop :
y = 0 ;
Then in Per-Record :
x = in0.id ;
if(x != y) {
< Taking some action> ;
}
else {
< Take some other action > ;
}
y = x ;
Input is auto-read. But I find control never go to 'else' section though there are such records.
#include<stdio.h>
#include<iostream.h>
int x ;
static int y ;
In Pre-Loop :
y = 0 ;
Then in Per-Record :
x = in0.id ;
if(x != y) {
< Taking some action> ;
}
else {
< Take some other action > ;
}
y = x ;
Input is auto-read. But I find control never go to 'else' section though there are such records.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You're going to have to incorporate some debugging statements in your code to capture the actual values of x and y and record them somewhere so that you can work out what's happening.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You only have access to the rows in the per-record code. Therefore you ought not to be writing your own loop. The variable called y is behaving properly like a static variable (I misunderstood your original requirement); try making it a regular variable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.