Hi James,
OK I think I see what you're getting at. Looks like you have some C experience.
You want to pass data to a function (sub-routine) similar to how you would in C. Something like this;
void convert(void)
{
temp_data = (temp_data * 9/5)+32; // convert C to F
temp_r = toBCD(temp_data); // convert to BCD for display
}
char toBCD(char bin_val)
{
char temp;
char retval;
temp = bin_val;
retval = 0;
while(1)
{
// get tens digit by multiple subtraction
// of 10 from bin_val
if (temp >= 10)
{
temp -= 10;
retval += 0x10; // increment tens digit
}
else // get ones digit by adding remainder
{
retval += temp; // adjusted result
break;
}
}
return(retval);
}
Unfortunately, you can't do it in PBP exactly like you would in C since there are no functions, arguments, etc like you have with C in BASIC.
Melanies example would work with a slight modification. It's just a little more work in BASIC VS C.
myVar as byte
myVar2 as byte
testVar as byte
loop:
testvar=myvar
gosub test
myvar=testvar
testvar=myvar2
gosub test
myvar2=testvar
goto loop
Bookmarks