Come: |
La funzione STRAN sostituisce una sottostringa con un'altra sottostringa in una stringa di caratteri. STRAN consente di modificare parte di una stringa di caratteri senza sostituire il campo completamente.
Per usare questa funzione, importare la funzione libreria MNTUWS. Per informazioni sull'importazione di questa libreria, consultare Chiamata di una funzione.
STRAN(string, substr1, substr2)
dove:
Alfanumerico
La stringa di caratteri di cui si desidera sostituire una sottostringa con un'altra, o un campo temporaneo che contiene la stringa.
Alfanumerico
La sottostringa da sostituire.
Alfanumerico
La sottostringa da inserire al posto di substr1.
STRAN sostituisce la parola DOOR con la parola Seater nel campo MODEL:
MAINTAIN FILE CAR
MODULE IMPORT (MNTUWS);
FOR ALL NEXT COUNTRY CAR MODEL INTO XSTK
WHERE MODEL CONTAINS 'DOOR'
COMPUTE XSTK.NEWMOD/A24;
COMPUTE I/I2=1;
REPEAT XSTK.FOCCOUNT
COMPUTE XSTK(I).NEWMOD=STRAN(XSTK(I).MODEL,'DOOR','SEATER');
TYPE "<<XSTK(I).CAR <<XSTK(I).MODEL <<XSTK(I).NEWMOD"
COMPUTE I=I+1;
ENDREPEAT
END
I seguenti sono valori campione per MODEL e i valori per il risultato della funzione STRAN:
CAR MODEL STRAN --- ----- ----- PEUGEOT 504 4 DOOR 504 4 SEATER ALFA ROMEO 2000 4 DOOR BERLINA 2000 4 SEATER BERLINA MASERATI DORA 2 DOOR DORA 2 SEATER DATSUN B210 2 DOOR AUTO B210 2 SEATER AUTO TOYOTA COROLLA 4 DOOR DIX AUTO COROLLA 4 SEATER DIX AUT AUDI 100 LS 2 DOOR AUTO 100 LS 2 SEATER AUTO BMW 2002 2 DOOR 2002 2 SEATER BMW 2002 2 DOOR AUTO 2002 2 SEATER AUTO BMW 3.0 SI 4 DOOR 3.0 SI 4 SEATER BMW 3.0 SI 4 DOOR AUTO 3.0 SI 4 SEATER AUTO BMW 530I 4 DOOR 530I 4 SEATER BMW 530I 4 DOOR AUTO 530I 4 SEATER AUTO
WebFOCUS |