Click here to Skip to main content
15,905,682 members
Home / Discussions / C#
   

C#

 
GeneralRe: multiple updates Pin
jparsons24-Jul-02 4:12
jparsons24-Jul-02 4:12 
GeneralRe: multiple updates Pin
Sarith Sutha24-Jul-02 18:50
Sarith Sutha24-Jul-02 18:50 
GeneralRe: multiple updates Pin
David Stone24-Jul-02 12:39
sitebuilderDavid Stone24-Jul-02 12:39 
GeneralRe: multiple updates Pin
SimonS24-Jul-02 21:37
SimonS24-Jul-02 21:37 
GeneralRe: multiple updates Pin
leppie24-Jul-02 23:03
leppie24-Jul-02 23:03 
GeneralRe: multiple updates Pin
SimonS24-Jul-02 21:33
SimonS24-Jul-02 21:33 
GeneralRe: multiple updates Pin
Sarith Sutha24-Jul-02 22:19
Sarith Sutha24-Jul-02 22:19 
GeneralRe: multiple updates Pin
SimonS24-Jul-02 23:09
SimonS24-Jul-02 23:09 
Here's the debug version of my script.
There are a number of assumptions that I took, viz: delimiter value and length and I didn't need to do any escaping of characters in "array".
If you have issues implementing this, feel free to contact me: simon_stewart@hotmail.com


DECLARE @Array varchar(50)
DECLARE @iStart int
DECLARE @iEleFound int
DECLARE @iMaxEleLen int
DECLARE @iNextDelimIndex int
DECLARE @iEleLen int

SET @Array = '1,2,3,4,5,6,7,8,9,65,66,67,100,101,102,654321'
SET @iStart = 0
SET @iEleFound = 0
SET @iMaxEleLen = 5
SET @iNextDelimIndex=0
SET @iEleLen =0

print '---------'
print 'LENGTH of string: ' + CAST(LEN(@Array) AS VARCHAR)
while CHARINDEX ( ',' , @Array,@iStart ) > 0 -- for each element in the array
begin
SET @iEleLen =1 --default
--if not ',' or ''
if (CAST(SUBSTRING(@Array, @iStart + 1, 1) AS char(1)) <> ',') and not(len (SUBSTRING (@Array, @iStart + 1, 1)) = 0)
begin--element found at this index

SET @iNextDelimIndex = CHARINDEX ( ',' , @Array,@iStart+1)
if(@iNextDelimIndex=0)
begin
SET @iNextDelimIndex = CAST (LEN(@Array) AS VARCHAR)+1
print 'latest element is next:'
end
SET @iEleLen = @iNextDelimIndex - @iStart
--DB function would occur here
print 'NEXT DELIM LOCATION-->' + CAST(@iNextDelimIndex AS VARCHAR(10))
print 'VALUE FOUND-->' + RTRIM( CAST(SUBSTRING(@Array, @iStart + 1, @iNextDelimIndex - @iStart-1) AS char(10)) ) + '<--'


SET @iEleFound = @iEleFound + 1


end

else --no element found at this index
begin
print 'do nothing'
end

SET @iStart = @iStart + @iEleLen

end --if (CAST(SUBSTRING(@Array, @iStart + 1, 1) AS char(1)) <> ',') and not(len (SUBSTRING (@Array, @iStart + 1, 1)) = 0)

print '------ ELEMENTS FOUND: ' + CAST(@iEleFound AS CHAR(2)) + ' ---------'


Cheers,
Simon

"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)

GeneralUsing current user credentials with Task Scheduler Library Pin
Keith Mai23-Jul-02 13:17
Keith Mai23-Jul-02 13:17 
Generalnetmodules Pin
jparsons23-Jul-02 10:37
jparsons23-Jul-02 10:37 
GeneralRe: netmodules Pin
Eric Gunnerson (msft)24-Jul-02 5:33
Eric Gunnerson (msft)24-Jul-02 5:33 
GeneralRe: netmodules Pin
jparsons24-Jul-02 5:50
jparsons24-Jul-02 5:50 
GeneralRe: netmodules Pin
Eric Gunnerson (msft)24-Jul-02 9:53
Eric Gunnerson (msft)24-Jul-02 9:53 
GeneralRe: netmodules Pin
jparsons25-Jul-02 3:01
jparsons25-Jul-02 3:01 
GeneralRe: netmodules Pin
Eric Gunnerson (msft)25-Jul-02 13:56
Eric Gunnerson (msft)25-Jul-02 13:56 
QuestionNotifyIcon text? Pin
sasdav23-Jul-02 7:26
sasdav23-Jul-02 7:26 
AnswerRe: NotifyIcon text? Pin
Rickard Andersson2023-Jul-02 8:24
Rickard Andersson2023-Jul-02 8:24 
AnswerRe: NotifyIcon text? Pin
Eric Gunnerson (msft)23-Jul-02 8:34
Eric Gunnerson (msft)23-Jul-02 8:34 
GeneralRe: NotifyIcon text? Pin
sasdav24-Jul-02 2:38
sasdav24-Jul-02 2:38 
GeneralRe: NotifyIcon text? Pin
Eric Gunnerson (msft)24-Jul-02 5:28
Eric Gunnerson (msft)24-Jul-02 5:28 
GeneralRe: NotifyIcon text? Pin
sasdav24-Jul-02 10:29
sasdav24-Jul-02 10:29 
GeneralRe: NotifyIcon text? Pin
Eric Gunnerson (msft)24-Jul-02 10:57
Eric Gunnerson (msft)24-Jul-02 10:57 
GeneralRe: NotifyIcon text? Pin
sasdav25-Jul-02 2:32
sasdav25-Jul-02 2:32 
QuestionCorrect way to try-catch in foreach loop? Pin
leppie22-Jul-02 22:15
leppie22-Jul-02 22:15 
AnswerRe: Correct way to try-catch in foreach loop? Pin
James T. Johnson22-Jul-02 23:08
James T. Johnson22-Jul-02 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.