How to replace just the first found space with tab for all lines in a variable?

Michael Kann mikekann at yahoo.com
Wed May 25 12:46:45 EDT 2011


Another way to do it. Watch for wrapped lines in email. Replace FAKETAB with tab after testing is complete.

on mouseUp

set itemDel to space

put fld 1 into v -- input

repeat for each line x in v

if space is in x then

  put item 1 of x into a
  put item 2 to -1 of x into b
  put a & "FAKETAB" & b & return after h

else

  put x & return after h

end if
 
end repeat

delete last char of h -- last return

put h into fld 2 -- output

end mouseUp


--- On Wed, 5/25/11, Ken Ray <kray at sonsothunder.com> wrote:

From: Ken Ray <kray at sonsothunder.com>
Subject: Re: How to replace just the first found space with tab for all lines in a variable?
To: "How to use LiveCode" <use-livecode at lists.runrev.com>
Date: Wednesday, May 25, 2011, 9:15 AM

Another possible approach is:

put fld 1 into tTemp
put empty into tResult
repeat for each line tLine in tTemp
  delete char offset(space,tLine) of tLine
  put tLine & cr after tResult
end repeat
delete char -1 of tResult
>> tResult has your data

Ken Ray
Sons of Thunder Software, Inc.

On May 25, 2011, at 6:20 AM, Jim Ault <jimaultwins at yahoo.com> wrote:

> Debugging hint when working with 'tab'
> Save time and agro by...
> 
> using "M" so that it is easy to see the replacements and extras.
> so try this
> 
> put tab into T
> put "M" into T --for debugging
> 
> put fld 1 into tempp
> repeat for each line LNN in tempp
>      put word 1 to -1 of LNN into cleanLine  --trim
>      put word 1 of cleanLine & T & word 2 to -1 of cleanLine & cr after newList
>   end repeat
>   ;put newList
>   --filter newList without T  --in case there should be empty lines
>   put 0 into prevNum
>   repeat until the number of chars in newList is prevNum
>      put the number of chars in newList into prevNum
>      replace (cr & T & cr) with ( cr & cr) in newList
>   end repeat
>   ;put newList
>   filter newList without empty
>   ;put newList
> 
> 
> Jim Ault
> Las Vegas
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list