Using R6 code in R5 database

Hi All,

I am working on redesigning a database for R6. Since it is using undocumented code that crashes the R6 client but works well in R5, adjustments are made to make it work with both R5 and R6, or at least that’s the idea. The following code is used:

@If(@TextToNumber(@Version) < 175;

@Do(

ResArrCheck := @FindFreeResource(ResourceList; “2”; tmpStartDateTime; tmpEndDateTime; “”; 50);

@If(@Elements(ResArrCheck) != @Elements(ResourceList); @Return(@Prompt([OK]; “Error”; Msg10)); “”));

@Do(

@For(n:=1; n<=@Elements(ResourceCategories); n:=n+1;

…etc

So basically it should do the first @Do for R5 clients, and the second @Do for R6. The problem is now, that it works ok on R6 clients but not in R5 anymore! If I check the code in the R5 designer, I see this:

@If(@TextToNumber(@Version) < 175;

@Do(

ResArrCheck ? @FindFreeResource(ResourceList; “2”; tmpStartDateTime; tmpEndDateTime; “”; 50);

@If(@Elements(ResArrCheck) != @Elements(ResourceList); @Return(@Prompt([OK]; “Error”; Msg10)); “”));

@Do(

ResourceLst ? @Name([Canonicalize]; ResourceList);

@?(n ?1; n<=@Elements(ResourceCategories); n? n + 1;

This looks like the problem is caused by a hickup in assigning the ResArrCheck variable, given the question mark there. The problem is, I cannot get rid of this question mark. Saving in R5 is not an option, and retyping the whole sentence does not work. There is another sentence with an @FindFreeResource command, this has a proper ‘:=’ where it should be.

Anyone any ideas how to get a proper sentence?

Subject: Solved

I finally fixed it… R5 cannot assign variables within a @Do loop: ‘:= can only appear at the beginning of a sentence’. Putting both lines in one solved the issue:

@If(@Elements(@FindFreeResource(ResourceList; “2”; tmpStartDateTime; tmpEndDateTime; “”; 50)) != @Elements(ResourceList); @Return(@Prompt([OK]; “Error”; Msg10))