Rockwell-automation 1771-DB Basic Module User Manual - Series A Manual de usuario Pagina 110

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 167
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 109
Operating Functions
Chapter 5
5–73
You can also use the ASC() operator to change individual characters in a
defined string.
Example:
u5 STRING 1000,40
u10 $(1)=“ABCDEFGHIJKL”
u20 PRINT $(1)
u30 ASC($(1),1)=75 REM: DECIMAL EQUIVALENT OF K
u40 PRINT $(1)
u50 ASC($(1),2)=ASC($(1),3)
u60 PRINT $(1)
uRUN
ABCDEFGHIJKL
KBCDEFGHIJKL
KCCDEFGHIJKL
In general, the ASC() operator lets you manipulate individual characters in
a string. A simple program can determine if two strings are identical.
Example:
u5 STRING 1000,40
u10 $(1)=“SECRET” : REM SECRET IS THE PASSWORD
u20 INPUT “WHAT’S THE PASSWORD – ”,$(2)
u30 FOR I=1 TO 6
u40 IF ASC($(1),I)=ASC($(2),I) THEN NEXT I ELSE 70
u50 PRINT “YOU GUESSED IT!”
u60 END
u70 PRINT “WRONG, TRY AGAIN” : GOTO 20
uRUN
WHAT’S THE PASSWORD – SECURE
WRONG, TRY AGAIN WHAT’S THE
PASSWORD – SECRET
YOU GUESSED IT
5.10.1
The ASC Operator
(continued)
Vista de pagina 109
1 2 ... 105 106 107 108 109 110 111 112 113 114 115 ... 166 167

Comentarios a estos manuales

Sin comentarios