Kdyer
(KiX Supporter)
2002-06-13 05:43 PM
VB-type Functions: CLNG, MID, REPLACE

Ideas..

REF - http://Kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=003474

If we dig back into the MS-Access helpfile, we should also be seeing - CLNG..

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q239104

I know this is not Access, but it would kinda neat to see some of these functions..

Another example, MID..

A cool function we can use from vb is Replace..

Kent

[ 13 June 2002, 17:43: Message edited by: kdyer ]


JensKalski
(Starting to like KiXtart)
2003-03-05 07:20 PM
Re: VB-type Functions: CLNG, MID, REPLACE

REPLACE would be very nice!

Sealeopard
(KiX Master)
2003-03-05 10:28 PM
Re: VB-type Functions: CLNG, MID, REPLACE

How about this replace:
code:
function replace($str,$src,$rpl)
$replace=join(split($str,$scr),$rpl)
endfunction



[ 05. March 2003, 22:29: Message edited by: sealeopard ]


Schuliebug
(Hey THIS is FUN)
2003-03-06 09:41 AM
Re: VB-type Functions: CLNG, MID, REPLACE

sealeopard,

Thats exactly the logic i use to see if a value is in an array:
code:
$_=$ArrayDelim+Join($Array,$ArrayDelim)+$ArrayDelim
If Instr($_,$ArrayDelim+$ValueToLookFor+$ArrayDelim)<>0
; In array !!
EndIf

It seems faster than looping the array... [Smile]

[ 06. March 2003, 09:42: Message edited by: Schuliebug ]


LonkeroAdministrator
(KiX Master Guru)
2003-03-06 10:12 AM
Re: VB-type Functions: CLNG, MID, REPLACE

schulie, what about:
code:
if -1<ascan($array,$searchfor)
"in array"
else
"not in array"
endif

[Wink]


Schuliebug
(Hey THIS is FUN)
2003-03-06 04:46 PM
Re: VB-type Functions: CLNG, MID, REPLACE

Totally right Lonkero, just a quick way for 4.12 maybe ? Ok ok, should upgrade to 4.20...

Lee Wilmott
(Starting to like KiXtart)
2003-03-06 05:14 PM
Re: VB-type Functions: CLNG, MID, REPLACE

A Replace() function would absolutely brilliant!

It would be nice to specify how many occurrences of the “text-to-replace” you would like replaced. (and maybe specify -1 to replace all occurrences).

One other thing...I know it is a "very" simple function but a RepeatStr() function would also be very helpful - this UDF appears in so many of my scripts.

Lee


JensKalski
(Starting to like KiXtart)
2003-03-06 07:12 PM
Re: VB-type Functions: CLNG, MID, REPLACE

Hi sealeopard,
it works fine. I doesn't know that join() works with more than one character as delimiter. In the helpfile stands "string character"?!?

Thanks for this workaround.

It would be nice if those little tricks and workaround find a way into the kixhelp.chm.


Sealeopard
(KiX Master)
2003-03-06 11:45 PM
Re: VB-type Functions: CLNG, MID, REPLACE

I'll post a formal Replace() UDF later tonight. Stay tuned.

Sealeopard
(KiX Master)
2003-03-07 03:22 AM
Re: VB-type Functions: CLNG, MID, REPLACE

Actually, there's no need for a new Replace() UDF as there's already one posted in the UDF Forum: Replace() - Replaces first or all occurrences of one string with another

LonkeroAdministrator
(KiX Master Guru)
2003-03-07 08:54 AM
Re: VB-type Functions: CLNG, MID, REPLACE

well, what about string limitations?
and speed of functioning?

I think the best way to do replace is just like showed in this topic.