29 October 2021, 01:30 | #1 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,126
|
AmigaOS 1.3 'tstdvc' , 'ctrflp' & 'ctrflpq' commands
Still with my HD install script, I needed to check if a given floppy disk was present in one of the available floppy drives but wanted to do it without the user being faced with a requester of the like of "No disk present in unit x" or "Please insert volume x in any drive" and that would have required a user action.
Thinking a bit about it I thought that a wider check could be more useful, meaning the ability to check for any given device and not only DF0: through DF3:. After thinking and testing a bit, I realised that my goal could be achieved quite simply with the help of two commands : - 'info' : to query the system for the required device - 'search' : to search if the previous query returned a valid answer Like this : Code:
tstdvc : .key DEVICE/A,QUIET/S .bra { .ket } info >t:ft{$$} {DEVICE} search >NIL: FROM t:ft{$$} SEARCH {DEVICE} QUIET if NOT WARN setenv DVC{$$} {DEVICE} skip mlk01 endif run >NIL: delete t:ft{$$} QUIET setenv DVC{$$} - if NOT "{QUIET}" EQ "QUIET" echo " *e[33mUnknown device!*e[0m" endif quit 5 lab mlk01 run >NIL: delete t:ft{$$} QUIET if NOT "{QUIET}" EQ "QUIET" echo " *e[33mValid!*e[0m" endif quit 0 Code:
getenv DVC<shell_number> Another possible check is to control if the user forgot to input the ':' at the end of the device name. And add them if so. The following code can be inserted as is between the 'endif' & the 'quit 0' lines : Code:
;------------------------------------------------------- ;contrôle si les ':' ont bien été mis à la fin du device ;------------------------------------------------------- echo >t:rmet{$$} "pa l//;<;sa//;m1;d;w" echo >PIPE:a{$$} {DEVICE} echo <PIPE:a{$$} >env:DVCe{$$}. LEN 1 ? edit >NIL: FROM env:DVCe{$$}. TO env:DVCe{$$} WITH t:rmet{$$} if NOT "$DVCe{$$}" EQ ":" echo >>env:DVC{$$} ":" NOLINE endif run >NIL: delete env:DVCe{$$}. env:DVCe{$$} t:rmet{$$} QUIET I then have adapted my code to perform the test specifically on floppy (from DF0: to DF3: ). Furthermore, to be sure the correct disk is present, a check on a specific file is performed. I also have created a loop that call recursively the script to minimize the size of the code. Code:
ctrflp : .key FICTR,BCLE/K,SCRNM/K,NODSK/K .bra { .ket } .def FICTR ".dmf0" .def BCLE 0 .def SCRNM "ctrflp" .def NODSK "No disk present" lab mlk01 ;------------------------------------------------------------- ;I. Le device DFx: est-il présent dans le système ? ;------------------------------------------------------------- info >t:ft{$$} DF{BCLE}: search >NIL: FROM t:ft{$$} SEARCH "DF{BCLE}:" QUIET if NOT WARN search >NIL: FROM t:ft{$$} SEARCH "{NODSK}" QUIET if WARN if EXISTS "DF{BCLE}:{FICTR}" setenv SRC{$$} "DF{BCLE}:" run >NIL: delete t:ft{$$} QUIET skip mlk02 endif endif endif ;------------------------------------------------------------- ;II. DFx: ou fichier non trouvé sur DFx:, test du lecteur suivant ;------------------------------------------------------------- ;echo "pas de disquette présente dans DF{BCLE}: " if NOT {BCLE} GE 3 run >NIL: eval VALUE1 {BCLE} OP + VALUE2 1 TO env:BCLE{$$} echo >t:ctrflpx "{SCRNM} BCLE " NOLINE getenv >>t:ctrflpx BCLE{$$} run >NIL: delete env:BCLE{$$} QUIET execute t:ctrflpx endif ;------------------------------------------------------------- ;III. Pas de disquette ou de fichier contrôle du tout ;------------------------------------------------------------- if {BCLE} EQ 3 date setenv SRC{$$} "-" run >NIL: delete t:ft{$$} QUIET echo "*N *e[33mMissing files.*e[0m " echo " *e[33mPlease check your source*e[0m " echo " *e[33mdisk before retrying.*e[0m " echo " *e[33mInstallation process aborted.*e[0m*N " endif quit 5 lab mlk02 ;------------------------------------------------------------- ;III. Fin du travail ;------------------------------------------------------------- ;(temps moyen chronométré pour contrôler de DF0: à DF3: 13 secondes) ;(temps moyen chronométré pour contrôler de DF0: à DF2: 9 secondes) ;(temps moyen chronométré pour contrôler de DF0: à DF1: 5 secondes) ;(temps moyen chronométré pour contrôler de DF0: à DF0: 2 seconde ) ;------------------------------------------------------------- quit 0 Here is anyway the version without the loop : Code:
ctrflq : .key FICTR,NODSK/K .bra { .ket } .def FICTR ".dmf0" .def NODSK "No disk present" lab mlk01 ;------------------------------------------------------------- ;I. Le device DF0: est-il présent dans le système ? ;------------------------------------------------------------- info >t:ft{$$} DF0: search >NIL: FROM t:ft{$$} SEARCH "DF0:" QUIET if NOT WARN search >NIL: FROM t:ft{$$} SEARCH "{NODSK}" QUIET if WARN if EXISTS "DF0:{FICTR}" setenv SRC{$$} "DF0:" skip mlk02 endif endif endif ;------------------------------------------------------------- info >t:ft{$$} DF1: search >NIL: FROM t:ft{$$} SEARCH "DF1:" QUIET if NOT WARN search >NIL: FROM t:ft{$$} SEARCH "{NODSK}" QUIET if WARN if EXISTS "DF1:{FICTR}" setenv SRC{$$} "DF1:" skip mlk02 endif endif endif ;------------------------------------------------------------- info >t:ft{$$} DF2: search >NIL: FROM t:ft{$$} SEARCH "DF2:" QUIET if NOT WARN search >NIL: FROM t:ft{$$} SEARCH "{NODSK}" QUIET if WARN if EXISTS "DF2:{FICTR}" setenv SRC{$$} "DF2:" skip mlk02 endif endif endif ;------------------------------------------------------------- info >t:ft{$$} DF3: search >NIL: FROM t:ft{$$} SEARCH "DF3:" QUIET if NOT WARN search >NIL: FROM t:ft{$$} SEARCH "{NODSK}" QUIET if WARN if EXISTS "DF3:{FICTR}" setenv SRC{$$} "DF3:" skip mlk02 endif endif endif ;------------------------------------------------------------- ;III. Si on arrive ici c'est qu'il n'y a pas de disquette ou de fichier contrôle du tout ;------------------------------------------------------------- setenv SRC{$$} "-" echo "*N *e[33mMissing files.*e[0m " echo " *e[33mPlease check your source*e[0m " echo " *e[33mdisk before retrying.*e[0m " echo " *e[33mInstallation process aborted.*e[0m*N " run >NIL: delete t:ft{$$} QUIET quit 5 lab mlk02 ;------------------------------------------------------------- ;III. Fin du travail ;------------------------------------------------------------- ;(temps moyen chronométré pour contrôler de DF0: à DF3: 4 secondes) ;(temps moyen chronométré pour contrôler de DF0: à DF2: 4 secondes) ;(temps moyen chronométré pour contrôler de DF0: à DF1: 3 secondes) ;(temps moyen chronométré pour contrôler de DF0: à DF0: 3 seconde ) ;------------------------------------------------------------- run >NIL: delete t:ft{$$} QUIET quit 0 Code:
getenv SRC<shell_number> |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
cybppc.device & AmigaOS 4.1 FE , problem | drluking | support.Hardware | 23 | 19 December 2021 20:57 |
VBCC & AmigaOS 3.2 NDK? | Warty | Coders. C/C++ | 20 | 18 June 2021 08:41 |
AmigaOS & lha | Ulysses13 | New to Emulation or Amiga scene | 4 | 04 June 2021 20:58 |
E-UAE for AmigaOS 4.1 help for commands | White | support.OtherUAE | 0 | 16 February 2018 15:55 |
Amal animation & HREV with joystick commands | Brick Nash | Coders. AMOS | 8 | 02 June 2016 18:32 |
|
|