Page 1 of 1 1
Topic Options
#17627 - 2002-02-19 07:29 AM Character stripping
Mick Callaghan Offline
Lurker

Registered: 2002-02-19
Posts: 2
Loc: Melbourne, Australia
Does anybody have any ideas on what I bet will be a really really simple job. Basically I want to strip sime punctuation marks ouut of a variable. ie : I want to get rid of the ":" from the @time so that I can create files with a time stamp as the suffix.

$filename=@time
? $filename
10:08:45
I want this to read 100845

Top
#17628 - 2002-02-19 08:00 AM Re: Character stripping
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: CA
Hello Mick and welcome to the board

Take a look at this post which shows an example of what I think your looking for.

System Time

Here is another link on similar issue different discussion.
Generalized base conversion

and one more
Removing certain characters from a string

One of these should help point you in the right direction. Hope this helps and if you still need further help please post again and ask.

Top
#17629 - 2002-02-19 11:06 AM Re: Character stripping
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
A very simple solution if you are using KiXtart version 4 is:
code:
$asTimeBits=Split(@TIME,":")
$sFileName="" + $asTimeBits[0] + $asTimeBits[1] + $asTimeBits[2]
? $sFileName


Top
#17630 - 2002-02-20 12:52 AM Re: Character stripping
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
If you need an UDF solution, I'm using this one since some times :

First param is the text to change
second param is the separator (can be anything, from 1 to x...x characters)
third param (optional) is the string used to replace separators

code:

Function TextReplace($sText,$sSeparator, optional $sNewSeparator)
Dim $Stock
dim $Element
for each $Element in Split($sText,$sSeparator)
If len($Stock)>0
$Stock=$Stock+""+$sNewSeparator+$Element
else
$Stock=$Element
endif
next
$TextReplace=$Stock
endfunction

[ 19 February 2002: Message edited by: Alex.H ]

_________________________
? getobject(Kixtart.org.Signature)

Top
#17631 - 2002-02-19 03:24 PM Re: Character stripping
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Or you could use the ever infamous "Squeeze" function from the function library:

Break On

?"RealTime="@TIME
?"SqueezeTime=" Squeeze(@TIME,":")

Exit 1


Function Squeeze($string1,$string2)
 while instr($string1,$string2)
  $string1 = substr($string1,1,instr($string1,$string2)-1) +
  substr($string1,instr($string1,$string2)+len($string2))
 loop
 $squeeze = $string1
EndFunction

SqueezeTime ... hmmm ... I like the sounds of that !

-Shawn

[ 19 February 2002: Message edited by: Shawn ]

Top
#17632 - 2002-02-19 10:44 PM Re: Character stripping
Mick Callaghan Offline
Lurker

Registered: 2002-02-19
Posts: 2
Loc: Melbourne, Australia
Thanks All - thats great!!!!
Top
#17633 - 2002-02-22 01:24 AM Re: Character stripping
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

An one line version to create filenames based on @time macro.

$file=Substr(@time,1,2)+Substr(@time,4,2)+Substr(@time,7,2)

Creation of unique UDFs is nice but sometimes it makes code hard to
maintain. In our opinion not really necessary.
The nicest one was Shawns script.
greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 661 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.03 seconds in which 0.012 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org