Revision 2

Date:
2005/10/19 00:34:41
Author:
gdshaw
Revision Log:
Added SysPath program.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • trunk/System/basic/SysPath

     
    1 REM This file is part of the RISC OS Packaging Project system application.
    2 REM Copyright � 2005 Graham Shaw.
    3 REM Redistribution and modification are permitted under the terms of the
    4 REM GNU General Public License (version 2 or any later version).
    5
    6 vlimit%=&100
    7 vcount%=0
    8 DIM versions%(vlimit%-1)
    9
    10 bsize%=256
    11 DIM buffer% (bsize%-1)
    12 pathname$="@"
    13 os_ver%=FNos_version
    14 offset%=0
    15 REPEAT
    16 SYS "OS_GBPB",9,pathname$,buffer%,1,offset%,bsize%,0 TO ,,,count%,offset%
    17 sd_ver%=FNsubdir_version(buffer%)
    18 IF (sd_ver%<>0) AND (sd_ver%<=os_ver%) THEN PROCadd_version(sd_ver%)
    19 UNTIL offset%=-1
    20
    21 PROCsort_versions
    22 PROCbuild_path
    23 END
    24
    25 DEF FNisdigit(C%)
    26 =(C%>=&30)AND(C%<=&3A)
    27
    28 DEF FNos_version
    29 LOCAL P%,V%
    30 V%=0
    31 SYS "XOS_Byte",0,0 TO P%
    32 P%=P%+4
    33 WHILE (?P%<>0) AND NOT FNisdigit(?P%)
    34 P%=P%+1
    35 ENDWHILE
    36 WHILE (?P%<>0) AND FNisdigit(?P%)
    37 V%=(V%*10+?P%-&30) MOD 100
    38 P%=P%+1
    39 ENDWHILE
    40 V%=V%*10
    41 IF (?P%=&2E) THEN
    42 P%=P%+1
    43 IF FNisdigit(?P%) THEN
    44 V%=V%+(?P%)-&30
    45 ENDIF
    46 ENDIF
    47 V%=V%*10
    48 =V%
    49
    50 DEF FNsubdir_version(buffer%)
    51 LOCAL P%,V%
    52 V%=0
    53 P%=buffer%
    54 WHILE (?P%<>0) AND FNisdigit(?P%)
    55 V%=V%*10+?P%-&30
    56 P%=P%+1
    57 ENDWHILE
    58 IF (?P%<>0) THEN V%=0
    59 =V%
    60
    61 DEF PROCadd_version(version%)
    62 IF vcount%<vlimit% THEN
    63 versions%(vcount%)=version%
    64 vcount%=vcount%+1
    65 ENDIF
    66 ENDPROC
    67
    68 DEF PROCsort_versions
    69 LOCAL I%,J%,V%
    70 I%=0
    71 WHILE I%<vcount%
    72 V%=versions%(I%)
    73 IF I%<>0 THEN
    74 J%=I%-1
    75 WHILE (J%<>0) AND (versions%(J%)>V%)
    76 versions%(J%+1)=versions%(J%)
    77 J%=J%-1
    78 ENDWHILE
    79 IF versions%(J%)>V% THEN
    80 versions%(J%+1)=versions%(J%)
    81 J%=J%-1
    82 ENDIF
    83 versions%(J%+1)=V%
    84 ENDIF
    85 I%=I%+1
    86 ENDWHILE
    87 ENDPROC
    88
    89 DEF PROCbuild_path
    90 LOCAL I%,V$
    91 PROCsetvarval("System$Path","<Sys$Path>")
    92 IF vcount%<>0 THEN
    93 FOR I%=0 TO vcount%-1
    94 V$=STR$(versions%(I%))
    95 PROCsetvarval("System$Path","Sys:"+V$+".,<System$Path>")
    96 NEXT
    97 ENDIF
    98 ENDPROC
    99
    100 DEF PROCsetvarval(N$,V$)
    101 SYS "OS_SetVarVal",N$,V$,LEN(V$),0,0
    102 ENDPROC