Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Google search


Poll
How big is your Baan-DB (just Data AND Indexes)
0 - 200 GB
18%
200 - 500 GB
26%
500 - 800 GB
3%
800 - 1200 GB
9%
1200 - 1500 GB
12%
1500 - 2000 GB
12%
> 2000 GB
21%
Total votes: 34

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 10th July 2018, 10:20
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
How to filter a wording
Baan: ERP LN 6.1 FP11 (Infor ERP 10.5)
C/S: None/Unknown

Hi,

Have any function can I filter a wording in a program script?

Example: I have formula like this "Width*L(125 * (W + Length)) + 3125AC + (125 * ((Wdth + L) - 125))"

How can i get it to be W*L(125 * (W + L)) + 3125 + (125 * ((W + L) - 125))?

Please advise. Thanks.
Reply With Quote
  #2  
Old 10th July 2018, 10:31
JaapJD's Avatar
JaapJD JaapJD is offline
Guru
 
Join Date: Sep 2002
Location: Netherlands
Posts: 803
JaapJD will become famous soon enoughJaapJD will become famous soon enough
Baan: BaanIV, BaanERP, ERP LN 6.1 - DB: Oracle, SQL Server - OS: Unix, Windows
Use str.replace() function.
Reply With Quote
Sponsored Links
  #3  
Old 10th July 2018, 13:00
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by JaapJD View Post
Use str.replace() function.
Hi,

Thanks for your reply.

May i know can i auto detect const string oldstr$? Because we have many different wording.

Example:source = Width*L(125 * (W + Length)) + 3125AC + (125 * ((Wdth + L) - 125))

The const string oldstr$ need how to write? So, that my formula be like this W*L(125 * (W + L)) + 3125 + (125 * ((W + L) - 125))?

target = str.replace$(source, ?, "")

Please advise. Thanks.
Reply With Quote
  #4  
Old 10th July 2018, 14:53
BChary's Avatar
BChary BChary is offline
Junior Member
 
Join Date: Apr 2016
Location: Poland
Posts: 13
BChary is on a distinguished road
Baan: Infor LN 10.4/10.5 - DB: SQL Server - OS: W10
Quote:
Originally Posted by tracylee View Post
Hi,

Thanks for your reply.

May i know can i auto detect const string oldstr$? Because we have many different wording.

Example:source = Width*L(125 * (W + Length)) + 3125AC + (125 * ((Wdth + L) - 125))

The const string oldstr$ need how to write? So, that my formula be like this W*L(125 * (W + L)) + 3125 + (125 * ((W + L) - 125))?

target = str.replace$(source, ?, "")

Please advise. Thanks.
you can try this code:
Code:
	long	expr_id, lng, length_res, pos_res
	string 	str_in(1000)
	string 	str_out(1000)
	string 	word(20)
	string 	word_abbrev(1)
	string 	tmp(4)
	boolean end.loop
	
	str_in 	= "Width*L(125 * (W + Length)) + 3125AC + (125 * ((Wdth + L) - 125))"
	str_out = str_in
	
	end.loop = false
	REPEAT
		expr_id	= expr.compile(""&quoted.string(str_out)&" IN ""[a-zA-Z][a-zA-Z][a-zA-Z]*""")
		lng   	= l.expr( expr_id )
		if(lng = 0)then
			end.loop = true
		else
			store.long( lng, tmp )
			length_res 	= load.short( tmp(1;2) ) 
			pos_res    	= load.short( tmp(3;2) ) 
			word 		= str.substring$(str_out, pos_res, pos_res+length_res)
			word_abbrev	= toupper$(str.substring$(word, 1, 2))
			
			| remove full word
			str_out = str.remove$(str_out, pos_res, len(word))
			
			| insert abbreviation in the place of the removed word
			str_out = str.insert$(str_out, pos_res, " "&word_abbrev&" ")
		endif
		
	UNTIL end.loop

	message(str_out)
This script should replace any word(made of 2 or more characters) into first letter of this word(uppercase + space on left and right side).
PS. Base on this example, you should try to fix a "3125AC". (Hint. your script must be placed before mine)

Last edited by BChary : 10th July 2018 at 15:51. Reason: replace str.replace$ with str.remove$ and str.insert$
Reply With Quote
  #5  
Old 11th July 2018, 05:14
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by BChary View Post
you can try this code:
Code:
	long	expr_id, lng, length_res, pos_res
	string 	str_in(1000)
	string 	str_out(1000)
	string 	word(20)
	string 	word_abbrev(1)
	string 	tmp(4)
	boolean end.loop
	
	str_in 	= "Width*L(125 * (W + Length)) + 3125AC + (125 * ((Wdth + L) - 125))"
	str_out = str_in
	
	end.loop = false
	REPEAT
		expr_id	= expr.compile(""&quoted.string(str_out)&" IN ""[a-zA-Z][a-zA-Z][a-zA-Z]*""")
		lng   	= l.expr( expr_id )
		if(lng = 0)then
			end.loop = true
		else
			store.long( lng, tmp )
			length_res 	= load.short( tmp(1;2) ) 
			pos_res    	= load.short( tmp(3;2) ) 
			word 		= str.substring$(str_out, pos_res, pos_res+length_res)
			word_abbrev	= toupper$(str.substring$(word, 1, 2))
			
			| remove full word
			str_out = str.remove$(str_out, pos_res, len(word))
			
			| insert abbreviation in the place of the removed word
			str_out = str.insert$(str_out, pos_res, " "&word_abbrev&" ")
		endif
		
	UNTIL end.loop

	message(str_out)
This script should replace any word(made of 2 or more characters) into first letter of this word(uppercase + space on left and right side).
PS. Base on this example, you should try to fix a "3125AC". (Hint. your script must be placed before mine)
Hi,

Thanks for your script. Very helpful to me. But I'm still facing another problem. After i get this formula and then I replace W = 2 and L = 3 on this formula but cannot get a correct value.

domain tcwght weight
domain tcmcs.str30 W, L
string str_out_with_value(1000)

str_out = W*L(125 * (W + L)) + 3125 + (125 * ((W + L) - 125))
str_out_with_value =2*3(125*(2+3))+3125+(125*((2+3)-125))

weight = lval(str_out_with_value)

Please advise. Thanks.
Reply With Quote
  #6  
Old 11th July 2018, 08:14
BChary's Avatar
BChary BChary is offline
Junior Member
 
Join Date: Apr 2016
Location: Poland
Posts: 13
BChary is on a distinguished road
Baan: Infor LN 10.4/10.5 - DB: SQL Server - OS: W10
lval() only change string in to long, by cutting off all numbers till end or first no-numeric character.
So string "2+3" become long 2, because "+" is not number.
Any mathematic operation is not performed on the string.
If you want to get value from mathematic formula you must to use:
Code:
	string 	math.string(100)
	long 	expr.id
	double 	result
	
	math.string = "2+3"
	expr.id	= expr.compile(math.string)
	result	= d.expr(expr.id)
	
	message(str$(result))
Reply With Quote
  #7  
Old 11th July 2018, 08:20
günther günther is offline
Guru
 
Join Date: Jan 2002
Location: Ehingen, Germany
Posts: 578
günther is on a distinguished road
Baan: IVc4 - DB: Informix - OS: HP-UX
An don't forget expr_free to give the allocated memory back.

Regards
Günther
Reply With Quote
  #8  
Old 12th July 2018, 11:43
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 71
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by BChary View Post
lval() only change string in to long, by cutting off all numbers till end or first no-numeric character.
So string "2+3" become long 2, because "+" is not number.
Any mathematic operation is not performed on the string.
If you want to get value from mathematic formula you must to use:
Code:
	string 	math.string(100)
	long 	expr.id
	double 	result
	
	math.string = "2+3"
	expr.id	= expr.compile(math.string)
	result	= d.expr(expr.id)
	
	message(str$(result))
Hi,

Thanks for your help. It's work well on my script. Thanks a lot. ^^
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Zoom Session does not refresh its filter value. eric.dizon Tools Development 4 9th December 2016 06:22
Filter on multiocc fields on Webtop pillai.ganesh Tools Development 0 14th February 2013 11:43
Filter not working VishalMistry Tools Administration & Installation 2 23rd April 2011 07:14
Enable fields after filter patriciosoria Tools Development 0 23rd January 2010 22:34
Problems with ttstpqbf (filter) en@frrom Tools Development 1 19th April 2005 12:56


All times are GMT +2. The time now is 21:07.


©2001-2018 - Baanboard.com - Baanforums.com