! THIS PROGRAM TESTS THE QUALITIES OF XCALL GLOBAL AND XCALL REPLAC
!
! SYNTAX: XCALL REPLAC,STRING,WHAT,WITH
!
! WHERE: STRING = DATA STRING TO BE MANIPULATED
! WHAT = STRING OF DATA THAT IS TO BE REPLACED
! WITH = STRING OF DATA TO REPLACE THE WHAT STRING WITH
! Description: Replace 1 string with another within a given string
! Similiar to VUE's REPLAC command
! Type: XCALL REPLAC,STRING,WHAT,WITH
! The WHAT variable will be replaced by the WITH variable
! within the STRING variable as long as the length of the
! STRING variable is long enough to handle the LEN(WITH)+
! the LEN(STRING).
! If the WHAT string is longer than the WITH string then
! the entire STRING will be truncated.
! If the WHAT string is shorter than the WITH string then
! the entire STRING will be expanded if the LEN(STRING) is
! long enough.
! If WITH string is empty then WHAT string will be replaced
! with nothing and the entire STRING will be truncated.
! WARNING: it will replace strings just as the vue REPLAC
! does. If WHAT=is and WITH=as it will change
! "this" to "thas"
! Example:
! STRING = a string variable any length
! WHAT = string to change, any length
! WITH = string to change WHAT to any length
! as long as the length + length of the rest of STRING
! is not greater than the mapped length of STRING
!
MAP1 STRING,S,80,"THE STRING THAT THE PROGRAM USES IS THIS ONE"
MAP1 WHAT,S,80,"THE"
MAP1 WITH,S,80,"A"
MAP1 SAVIT,S,80
SAVIT=STRING
? TAB(-1,0);"XCALL REPLAC and XCALL GLOBAL Demonstation Program"
? TAB(3,1);"String = ";STRING
? TAB(4,1);"What = ";WHAT
? TAB(5,1);"With = ";WITH
? TAB(6,1);"String Before XCALL REPLAC = :";STRING
XCALL REPLAC,STRING,WHAT,WITH
? TAB(7,1);"String After XCALL REPLAC = :";STRING
STRING=SAVIT
? TAB(9,1);"String = ";STRING
? TAB(10,1);"What = ";WHAT
? TAB(11,1);"With = ";WITH
? TAB(12,1);"String Before XCALL GLOBAL = :";STRING
XCALL GLOBAL,STRING,WHAT,WITH
? TAB(13,1);"String After XCALL GLOBAL = :";STRING
MORE:
? tab(14,1);tab(-1,10);
? TAB(15,1);"Enter a String ";:INPUT "",STRING
? TAB(16,1);"Enter WHAT to Replace ";:INPUT "",WHAT
? TAB(17,1);"Enter what to replace it WITH ";:INPUT "",WITH
? TAB(18,1);"String = :";STRING
? TAB(19,1);"What = :";WHAT
? tab(20,1);"With = :";WITH
SAVIT=""
SAVIT=STRING
XCALL REPLAC,STRING,WHAT,WITH
? tab(21,1);"After xcall REPLAC =:";STRING
STRING=""
STRING=SAVIT
XCALL GLOBAL,STRING,WHAT,WITH
? TAB(22,1);"After xcall GLOBAL =:";STRING
? TAB(23,1);"More ? ";:INPUT Y$
IF UCS(Y$)="Y" THEN GOTO MORE
? TAB(-1,0);
END