(How) Is it possible for a Program to determine the version number of the Editor?

AllyCat

Senior Member
Hi,

As I have hinted on the forum several times, I'm in the process of developing an "improved" READINTERNALTEMP algorithm. Ideally, it should use the "IT_RAW_ ...." command parameter, but unfortunately PE5 and PE6 (and more worryingly AxePad 1.5.0 and 1.5.1) return different values (due to bugs in the earlier versions).

Is there any (practical) way for the program to determine how it should treat the data from READINTERNALTEMP IT_RAW_ ..... ? My development routines already have more #defines than I (and no doubt others) really want to see. ;)

Thanks, Alan.
 

AllyCat

Senior Member
Hi,

Thanks technical. That might help me, but I'd prefer not to update my PE5 compiler (because I know others may not have done so) and because PE5 produces more compact READINTERNALTEMP code (even with a bug workaround added) than does PE6.

So, I'm more concerned about "publishing" a Program which may produce the wrong results if the user hasn't upgraded to the latest version of the Editor (and I'm afraid I still prefer PE5 for "quick and dirty" results).

My alternative is to avoid using the READINTERNALTEMP instruction and instead code it as a rather obscure (to others) sequence of POKE/PEEK SFR commands (which is still more compact than produced by PE6, but not PE5).

Thanks, Alan.
 

hippy

Technical Support
Staff member
There is no automatic way I know of but you could add "#DEFINE PE5" ( leave in for PE5, comment out for PE6 ), then use #IFDEF and/or #IFNDEF to test for the definition being present or not.

One option is to force PE5 or PE6 to be defined so the user has to select the correct editor when the code is first used ...

Code:
; Uncomment one of the lines below -

; #Define PE5
; #Define PE6

#IfNDef PE5
  #IfNDef PE6
    #Error Must include #DEFINE PE5 or #DEFINE PE6
  #EndIf
#Else
  #IfDef PE6
    #Error Cannot include both #DEFINE PE5 and #DEFINE PE6
  #EndIf
#EndIf

Do
  #IfDef PE5
    SerTxd( "Compiled via PE5", CR, LF )
  #Else
    SerTxd( "Compiled via PE6", CR, LF )
  #EndIf
Loop
 

AllyCat

Senior Member
Hi.

Thanks hippy. Yes that's what I'm doing now, but as I use both PE5 and PE6, it's easy to make mistakes. And I wonder if users of AxePad know (or care) whether they're running 1.5.0 or 1.5.1.

The pragmatic solution I adopted for the code that I've already published , is to add the RAW_L and RAW_H results together, so it doesn't matter if they're swapped (by PE5), But that can't be used below the "4-diodes" threshold level of about Vdd = 3.2 volts (or 4v in the PICaxe Manual).

My algorithm could read both RAW_L and RAW_H and then swap them around if incorrect. But that takes away a lot of the "elegance" of the code, particularly when a single RAW READINTERNALTEMP in PE6 uses 25 bytes of codespace, compared with the 8 bytes of PE5.

Cheers, Alan.
 

AllyCat

Senior Member
Hi Tex,

Personally I've never (yet) run out of codespace (perhaps because I'm careful) but there are sometimes posts on the forum from people who have. ;)

However, a particular target for my code is that it can be "dropped into" almost any (M2) development program, at the same time as one can add a CALIBADC routine to validate the power supply. But it's difficult to claim a subroutine of probably 100+ bytes (with 50 bytes "wasted" on READINTERNALTEMPs, plus word-swapping code, etc.) is a trivial addition or unconditionally "better" than the (already wasteful) 36 bytes of the resident functions, particularly when using only an 08M2.

Cheers, Alan.
 
Top