Example String find 002
|
(defun findString(matchString targetString)
regs:(m M t T n
CharPointer:mPointer CharPointer:tPointer
tempTarget tempMatch)
vars:((result false))
;; Initialize the match and target pointers and lengths.
;; Note: We use the faster assembler length instructions,
;; but we must eliminate any null characters.
(vmregRunInHardware startNoLoad:)
(vmregObjLength matchString M)
(vmregObjLength targetString T)
;; assign the register pointers to point to the string inputs
(setq mPointer matchString)
(setq tPointer targetString)
;; eliminate null characters
(if (= (setq tempMatch mPointer[M]) 0) (-- M))
(if (= (setq tempMatch tPointer[T]) 0) (-- T))
(-= T M)
;; loop for all characters in the target String
(loop for t from 0 until T do
(loop for m from 0 until M do
;; set the next character in the target string to be compared
(setq tempTarget tPointer[(setq n (+ t m))])
;; set the next character in the match string to be compared
(setq tempMatch mPointer[m])
(if (<> tempTarget tempMatch) (goto Next:))
) ;; end of loop for matchString
(setq result t)
(goto Last:)
Next::
) ;; end of loop for target String
Last::
(vmregRunInHardware stopNoSave:)
result)
Returns:
Returns:
Here are examples of the find function at work.
String find 001 | String find 002 |
Here is the link to the current function used in this example.
Here are a number of links to other related functions.
member(#void) | substring(#void) | mid(#void) |
Here are the links to the data types of the arguments used in this example. Here are a number of links to examples having similar argument types.
String
Vector
Integer
Analytic Information Server (AIS)AIS Component Systems
|