Joe Strazzere - All Things Quality

Visit my new blog at http://strazzere.blogspot.com/


December 1, 2005 - WinTask - CounterString

Posted in WinTask
'
' CounterString.src
'
' Generate a "Counter String" similar to James Bach's example
 
'counterstring {num} [{char}]
'produces a special string of length {num} that counts its own characters.
'"counterstring 10" would produce "*3*5*7*10*" which is a ten-character long string,
'such that each asterisk is at a position in the string equal to the number that precedes it.
'This is useful for pasting into fields that cut off text,
'so that you can tell how many characters were actually pasted.
'You can specify a separator other than asterisk. "counterstring 15 A" would produce "A3A5A7A9A12A15A"
 
'"*3*5*7*10*13*"
 
i=1
Marker$="*"
Starter$="["
Terminator$="]"
CounterString$=Starter$
targetlen=13
done=0
While done = 0
 MyLen$=Str$(Len(CounterString$)+1)
 Point$=Str$(Len(CounterString$)+Len(MyLen$)+1)
 CounterString$=CounterString$+Point$+Marker$
 If Len(CounterString$) > targetlen then
  done=1
  CounterString$=Left$(CounterString$,targetlen)
  End$=Str$(Len(CounterString$))+Terminator$
  CounterString$=Left$(CounterString$,targetlen - Len(End$))+End$
 Else
  i=i+1
 EndIf
Wend
 
msgbox(CounterString$)



Any comments on this article?
Email Me


<- Last Page :: Next Page ->

About Me

A gathering place for information and ideas about Quality Assurance, Testing, and other useful topics.

Problems cannot be solved by the same level of thinking that created them. - A. Einstein

Search This Site

Translate This Site

RSS Feed

Subscribe

Twitter

@jstrazzere

Categories

Life
QA
Sports
Tools
WinTask
Work in General

What I'm Reading Now