The text of a manual · part 6 of 9
PT630 Portable Terminal Programming Reference Guide: BIOS and System Functions, pages 41 to 49
Pages 41 to 49 of 73, from PT630 Portable Terminal Programming Reference Guide
The original document is the PDF (2.0 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Unitech PT630
Page 41
PT630 Programming Reference Guide Page 41 of 59 -----------------------------------------------------------------------------------------------------------------1.5.28.4 Read File with Handle Entry Parameter: AH = 3FH BX = Handle of file CX = number of bytes to read DS:DX ; pointer to data buffer Return Value: if success, AX = number of bytes read and CARRY flag is cleared, data in buffer if failed, AX = 6 and CARRY flag is set Example: int TS_read_file(int hdl,int cnt,char *str) { segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); regs.h.ah=0x3f; regs.x.cx=cnt; regs.x.bx=hdl; int86x(0x21,®s,®s,&segregs); if ((regs.x.cflag & 0x01) == 0) return(regs.x.ax); else return(-1); } 1.5.28.5
Write File with Handle Entry Parameter: AH = 40H BX = Handle of file CX = number of bytes to write DS:DX ; pointer to data buffer Returned Value: if success, AX = number of written bytes and CARRY flag is cleared if failed, AX = 6 and CARRY flag is set Example: int TS_write_file(int hdl,int cnt,char *str) { segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); regs.h.ah=0x40; regs.x.bx=hdl; regs.x.cx=cnt; int86x(0x21,®s,®s,&segregs); if ((regs.x.cflag & 0x01) == 0) return(regs.x.ax); else return(-1); }
Page 42
PT630 Programming Reference Guide Page 42 of 59 -----------------------------------------------------------------------------------------------------------------1.5.28.6 Delete File Entry Parameter: AH = 41H DS:DX ; pointer to file name buffer Return Value: if success, CARRY flag is cleared if failed, AX = 2 and CARRY flag is set Example: int TS_delete_file(char *fn) { TD_intdos_O(0x41,0,fn); if ((regs.x.cflag & 0x01) == 0) return(1); else return(-1); } 1.5.28.7
Move File Pointer Entry Parameter: AH = 42H AL = 0 ; offset from beginning 1 ; offset from current 2 ; offset from end BX = Handle of file CX = most significant half of 32 bits offset DX = least significant half of 32 bits offset Return Value: if success, CARRY flag is cleared AX = least significant half of new current position DX = most significant half of new current position if failed, CARRY flag is set AX = 6 Example: long TS_seek_file(int hdl,int type,long loc) { union LONG_III aa; regs.h.ah=0x42; regs.h.al=(unsigned char)type; regs.x.bx=hdl; aa.l.ll = loc; regs.x.cx=aa.i.ii2; regs.x.dx=aa.i.ii1; int86(0x21,®s,®s); aa.i.ii2=regs.x.dx; aa.i.ii1=regs.x.ax; if ((regs.x.cflag & 0x01) == 0) return(aa.l.ll); else return(-1L); }
Page 43
PT630 Programming Reference Guide Page 43 of 59 -----------------------------------------------------------------------------------------------------------------1.5.28.8 Search Character Beginning at the Current File Position Entry Parameter: AH = 42H AL = 3 ; search forward (to the end of file) 4 ; search backward (to the beginning of file) BX = file handle CX = n ; search nth matched character DL = character Return Value: 1) If character is found: Carry flag = clear DX:AX = pointer to current file position (at the position of matched character) If character is not found: Carry flag = set CX = total matched times DX:AX = pointer to current file position (not changed) 1.5.28.9
Search String in Formatted Data File Beginning at the Current Position Entry Parameter: AH = 42H AL = 5 ; search forward (to the end of file) 6 ; search backward (to the beginning of file) BX = file handle CH = n ; Total field number in the data record CL = m ; search mth field DS:DX = pointer to parameter block Structure of parameter block for non-fixed length record data file: String length : 1 byte String without ‘\0’ terminator : N bytes 0x00 1 byte Field separator character : 1 byte Structure of parameter block for fixed length record data file: String length : 1 byte String without ‘\0’ terminator : N bytes Field #1 length: 1 byte Field #2 length: 1 byte .. .. .. Field #n length: 1 byte Return Value: 1) If string is found: Carry flag = clear DX:AX = pointer to current file position (at the beginning of the matched string) 2) If string is not found: Carry flag = set DX:AX = pointer to current file position (not changed)
Page 44
PT630 Programming Reference Guide Page 44 of 59 -----------------------------------------------------------------------------------------------------------------1.5.28.10 Insert / Delete Data Block to / from File at the Current Position Entry Parameter: AH = 42H AL = 7 ; insert 8 ; delete BX = file handle CX = block length in bytes Return Value: 1) If the function is successful: Carry flag = clear DX:AX = pointer to current file position (not changed) 2) If the function fails: Carry flag = set DX:AX = pointer to current file position (not changed) Note: For insertion, the content of the inserted data block is undefined. 1.5.28.11 Rename File Entry Parameter:
AH = 56H DS:DX ; pointer to old file name string ES:DI ; pointer to new file name string Return Value: if success, AH = 0 and CARRY flag is cleared if failed, AH = 1 and CARRY flag is set Example: int TS_rename_file(char *inf,char far *outf) { segregs.ds = FP_SEG(inf); regs.x.dx = FP_OFF(inf); segregs.es = FP_SEG(outf); regs.x.di = FP_OFF(outf); regs.h.ah=0x56; int86x(0x21,®s,®s,&segregs); if ((regs.x.cflag & 0x01) == 0) return(regs.x.ax); else return(-1); }
1.5.28.12 Create New File Entry Parameter: AH = 5BH DS:DX ; pointer to file name string Return Value: if success, CARRY flag is cleared AX = file Handle if failed, CARRY flay is set AX = 04H ; too many open files 50H ; file exists Note: If the specified file already exists, the function fails. Example: int TS_create_new_file(char *fn) { regs.h.ah=0x5B; segregs.ds = FP_SEG(fn); regs.x.dx = FP_OFF(fn); if ((regs.x.cflag & 0x01) == 1) return(-1); else return(regs.x.ax); }
Page 45
PT630 Programming Reference Guide Page 45 of 59 -----------------------------------------------------------------------------------------------------------------1.5.29 Allocate Memory Entry Parameter: AH = 48H BX = block size in paragraphs (16 bytes) to be allocated Return Value: if success, CARRY flag is cleared AX = segment address of block allocated if failed , CARRY flag is set AX = error code BX = largest available memory block in paragraphs Example: int TS_alloc_mem(unsigned int size,unsigned char far *str,int *free) { unsigned long aa; regs.h.ah=0x48; regs.x.bx=size; int86(0x21,®s,®s); *free = regs.x.bx; aa = (unsigned long)regs.x.ax * 10000L; str = (unsigned char far *)aa; if ((regs.x.cflag & 0x01) == 0) return(1); else return(-1); }
1.5.30 Free Allocated Memory Entry Parameter: AH = 49H ES = segment address of block to be freed Return Value: if success , CARRY flag is cleared if failed , CARRY flag is set AX = error code Example: int TS_free_mem(unsigned char far *str) { unsigned long aa; regs.h.ah=0x49; segregs.es=FP_SEG(str); int86x(0x21,®s,®s,&segregs); if ((regs.x.cflag & 0x01) == 0) return(1); else return(-1); }
Page 46
PT630 Programming Reference Guide Page 46 of 59 -----------------------------------------------------------------------------------------------------------------1.5.31 Modify Allocated Memory Block Entry Parameter: AH = 4AH ES = segment address of the block to resize BX = new block size in paragraphs (16 bytes) Returned Value: if success , CARRY flag is cleared if failed , CARRY flag is set AX = error code Example: int TS_modify_alloc_mem(unsigned int size,unsigned char far *str,int *free) { unsigned long aa; regs.h.ah=0x4a; regs.x.bx=size; segregs.ds = FP_SEG(str); int86(0x21,®s,®s); *free = regs.x.bx; if ((regs.x.cflag & 0x01) == 0) return(1); else return(-1); }
1.5.32 Run specified program Entry Parameter: AH = 4BH AL = 3 DS:DX ; pointer toprogram name Return Value: if success, AX = Handle and CARRY flag is cleared if failed , AX = 2 and CARRY flag is set void TS_Run(char far *str) { regs.h.ah=0x4b; regs.h.al=3; segregs.ds=FP_SEG(str); segregs.x.dx=FP_OFF(str); int86x(0x21, ®s, ®s, &segregs); }
1.5.33 End Program Entry Parameter: AH = 4CH AL = program-defined return value Return Value: None Example: void TS_end_program(int ret_code) { regs.h.ah= 0x4C; regs.h.al= (unsigned char)ret_code; int86(0x21,®s,®s); }
Page 47
PT630 Programming Reference Guide Page 47 of 59 -----------------------------------------------------------------------------------------------------------------1.5.34 Read Data from Scanner Port Entry Parameter: AH = 50H DS:DX ; pointer to data buffer Return Value: 1) AX =0 ; has data input DS:DX ; pointer to input data string BL = 1 ; Code 39 2 ; Interleaved 2 of 5 3 ; Codabar 5 ; Code 128 6 ; EAN 128 7 ; Code 93 11H ; UPC-A 12H ; UPC-E 13H ; EAN-13 14H ; EAN-8 21H ; User Code 1 (TRIOPTIC) 22H ; User Code 2 (TOSHIBA) CL = 0 ; scan direction from left to right 1 ; scan direction from right to left 2) AX = 1 ; no data input Example: int TD_get_bar1(unsigned char *str,int wait,int *type,int *dir) { int i; do { regs.h.ah=0x50; segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); int86x(0x21,®s,®s,&segregs); i = regs.x.ax; *type = regs.h.bl; *dir = regs.h.cl; } while (wait && i); return(i); }
1.5.35 Set Scanner Port Entry Parameter: AH = 51H AL = 0 ; disable scanner port 1 ; enable scanner Return Value: None Example: void TD_set_bar(int status) { regs.h.ah= 0x51; regs.h.al= (unsigned char)status; int86(0x21,®s,®s); }
Page 48
PT630 Programming Reference Guide Page 48 of 59 -----------------------------------------------------------------------------------------------------------------1.5.36 Receive Data from RS232 Port in MULTIPOINT Protocol Entry Parameter: AH = 5CH DS:DX ; pointer to data buffer (max. 256 bytes) Returned Value: AL = 0 ; input successful 1 ; no data DS:DX = input buffer pointer Note: 1) Only for MULTIPOINT communication protocol 2) Data is sent by Host computer using ESC ‘0’ command Example: int TC_str_I(unsigned char *str,int wait) { do { regs.h.ah=0x5C segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); int86x(0x21,®s,®s,&segregs); } while (wait && regs.h.al); return(regs.h.al); } 1.5.37 Send Data to RS232 Port in MULTIPOINT Protocol (Buffered Output) Entry Parameter: AH = 5DH DS:DX ; pointer to buffer with output data (max. 256 bytes) Return Value: AL =0 ; successful 1 ; failed (output buffer already has data to be sent) Note: 1) Only for MULTIPOINT communication protocol 2) PT630 will send data out when polled by Host computer Example: int TC_str_O(unsigned char *str,int wait) { do { segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); regs.h.ah=0x5D; int86x(0x21,®s,®s,&segregs); return(regs.h.al); } while (wait && regs.h.al); return(regs.h.al); }
Page 49
PT630 Programming Reference Guide Page 49 of 59 -----------------------------------------------------------------------------------------------------------------1.5.38 Check RS232 Output Buffer Status in MULTIPOINT Protocol Entry Parameter: AH = 5EH Returned Value: AL = 0 ; output buffer is empty 1 ; output buffer has data Note: 1) Only for MULTIPOINT communication protocol 2) The function can be used to check if data has been sent to Host computer. Example: int TC_ready(int wait) { do { regs.h.ah= 0x5E; int86(0x21,®s,®s); } while (wait && regs.h.al); return(regs.h.al); }