--- title: "Offset_bas" type: "article" slug: "offset_bas" url: "http://localhost/article/offset_bas/" markdown_url: "http://localhost/article/offset_bas.md" published_at: "2026-11-11T11:07:16+00:00" modified_at: "2026-11-11T11:07:16+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "OFFSET_BAS, a SuperBASIC formatted-number procedure in the spirit of PRINT USING, by J.C. Touzin. Called with a channel, the number, the integer and decimal widths and a leading sign character, it lines up decimal points and removes the E of scientific notation for numbers of a million or more and for some numbers between -1 and +1, using helper procedures not_scient and million. A demonstration loop prints the QL's own output in window 0 beside the procedure's in window 1, and the author invites readers to improve it." post_tag: - name: "French language" slug: "french-language" taxonomy: "post_tag" url: "http://localhost/tag/french-language/" - name: "QL" slug: "ql" taxonomy: "post_tag" url: "http://localhost/tag/ql/" - name: "Superbasic (programming language)" slug: "superbasic-programming-language" taxonomy: "post_tag" url: "http://localhost/tag/superbasic-programming-language/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Sinclair QL" slug: "sinclair-ql" taxonomy: "model" url: "http://localhost/model/sinclair-ql/" indiv: - name: "Jean-Claude Touzin" slug: "jean-claude-touzin" taxonomy: "indiv" url: "http://localhost/indiv/jean-claude-touzin/" publication: "QL_DOC" publication_r: id: 52925 title: "QL_DOC" type: "periodical" url: "http://localhost/periodical/ql_doc/" authors: "Jean-Claude Touzin" issue: "6" issues_articles: - id: 76716 title: "QL_DOC n6" type: "issue" url: "http://localhost/issue/ql_doc-n6/" pages: "18-20" pubdate: "October-November 1988" archive_link: false volumeissue: "n6" --- # Offset_bas **In English:** OFFSET_BAS, a SuperBASIC formatted-number procedure in the spirit of PRINT USING, by [J.C. Touzin](http://localhost/indiv/jean-claude-touzin/). Called with a channel, the number, the integer and decimal widths and a leading sign character, it lines up decimal points and removes the E of scientific notation for numbers of a million or more and for some numbers between -1 and +1, using helper procedures not_scient and million. A demonstration loop prints the QL's own output in window 0 beside the procedure's in window 1, and the author invites readers to improve it. *The article below is in French, as printed in QL_DOC n6 (October-November 1988).* *** Il s’agit d’une procédure pour imprimer les nombres là où on les veut. Comme j’aime me démarquer, je l’ai appellée “OFFSET” au lieu de “PRINT USING”. Elle permet d’afficher les points décimaux bien en ligne, et elle enlève les “E” de la notation scientifique pour les nombres d’un million et plus et pour certains nombres entre -1 et +1. RUNner l’exemple pour voir la procédure en action. L’affichage standard du QL est dans la fenêtre 0, la procédure dans la 1. On appelle la procédure en indiquant le # du canal, le nombre à afficher, les entiers et les décimales, ainsi que le signe qu’on désire avant le nombre (“$”,”#” ou ” ” si rien avant le nombre). Noter qu’il faudra enlever les ! ! de la ligne 25300 qui ne sont là que pour l’exemple. Ensuite, comme le AT est indépendant du PRINT en SUPERbasic, il est facile de positionner le PRINT où on veut en employant AT avant d’appeler cette procédure. Si des améliorations sont apportées à cette procédure par un lecteur de QL_DOC j’aimerais bien en prendre connaissance. Par exemple, peut-être est-elle un peu longue? Jean-Claude Touzin C.P. 41 La Sarre Québec J9Z 2X4 [phone number omitted] ``` > OFFSET_BAS par J.C. TOUZIN 25000 c=1: e=8: d=2: s$="$" 25010 WINDOW 512,202,0,0: CLS 25020 FOR v_b=-2 TO 2 STEP 9E-2, 800000 TO 2.8E6 STEP 200000 25030 PRINT#0, !v_b! : offset c,v_b,e,d,s$ 25040 END FOR v_b 25041 : 25150 DEFine PROCedure offset (canal, var, entier, dec, signe$) 25160 LOCal arrondi,place_point,var$,debut,fin 25170 arrondi=10^-dec * INT((var+5 * 10^-(dec+1)) * 10^dec) 25180 arrondi$=arrondi 25190 IF ("E" INSTR arrondi$)<>0: not_scient arrondi$ 25200 var$=(FILL$(" ",9)) & signe$ & arrondi$ & (FILL$("0",10)) 25210 place_point=("." INSTR var$) 25220 IF place_point <> 0 25230 debut=place_point-entier 25240 ELSE 25250 var$(LEN(var$)-9)="." 25260 debut=LEN(var$)-9-entier 25270 END IF 25280 IF dec=0: fin=debut+entier-1: ELSE fin=debut+dec+entier 25290 var$=var$(debut TO fin) 25300 PRINT#canal, ! var$ ! 25310 END DEFine offset 25311 : 25320 DEFine PROCedure not_scient (arrondi$) 25330 place_E=("E" INSTR arrondi$) 25340 moins=("-" INSTR arrondi$ (1 TO 1)) 25350 moins_E=("-" INSTR arrondi$ (2 TO)) 25360 ou_point=("." INSTR arrondi$) 25370 IF moins_E=0: million arrondi$: RETurn 25380 IF moins_E<>0: nbre_dec=arrondi$(moins_E+2 TO): ELSE nbre_dec=arrondi$(place_E+1 TO) 25390 arrondi$=arrondi$(1 TO place_E-1) 25400 IF ou_point<>0: arrondi_2$= arrondi$ (1 TO ou_point-1) & arrondi$ (ou_point+1 TO ): ELSE arrondi_2$=arrondi$ 25410 rempli$=FILL$("0", nbre_dec-1) 25420 IF moins<>0: arrondi$="-." & rempli$ & arrondi_2$(2 TO): ELSE arrondi$="." & rempli$ & arrondi_2$ 25430 END DEFine not_scient 25431 : 25440 DEFine PROCedure million (arrondi$) 25450 vers_droite=arrondi$(place_E+1 TO) 25460 arrondi$=arrondi$(1 TO place_E -1) 25470 IF ou_point=0 25480 rempli$=FILL$("0",vers_droite) 25490 arrondi$=arrondi$ & rempli$ 25500 END IF 25510 IF ou_point<>0 25520 rempli$=arrondi$(ou_point +1 TO place_E -1) 25530 long=LEN(rempli$) 25540 IF long< vers_droite: rempli$=rempli$ & FILL$("0", vers_droite-long) 25550 arrondi$=arrondi$(1 TO ou_point-1) & rempli$ 25560 END IF 25570 END DEFine million ```