Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TextMerge()
Message
From
30/03/2019 05:43:43
 
 
To
29/03/2019 12:38:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01667676
Message ID:
01667749
Views:
68
Hi Cetin,

What you think about this solution (I've used UDF inside textmerge function) ?
CLEAR ALL
CLEAR

CLEAR ALL
CLEAR
SET SAFETY OFF


LOCAL lcTranslatethis,lcTranslatethisStep1,lcTranslated


CREATE TABLE _tempm (tekst1 M)

TEXT TO mtekst1 noshow		&& samo da napuni tabelu tj memo polje

 First line : <#_str1#>
 Second line: <#_str2#>  and then again <#_str10,_str9#>  and  <#_str8,_str7#>  for the end
 Third line: <#_str16,_str15#> 
 
 
ENDTEXT

INSERT INTO _tempm (tekst1) VALUES (mtekst1)
BROWSE  NOCAPTIONS                                            && for test - I can change memo filed

CREATE table _temp (idtekst c(50), tekst c(50) )
INDEX on idtekst TAG idtekst

FOR i=1 TO 20                             && this is used only for fill table _tempm
	IF  MOD(i,2)=0
		mvarId="_str"+TRANSFORM(i)+","+"_str"+TRANSFORM(i-1)
		mvarTekst="This is tekst_"+TRANSFORM(i)+","+"..."+TRANSFORM(i-1)
		INSERT INTO _temp(idtekst, tekst) VALUES (mvarid,mvartekst)
	ELSE
		INSERT INTO _temp(idtekst, tekst) VALUES ("_str"+TRANSFORM(i), "This is tekst_"+TRANSFORM(i))
	ENDIF
		
ENDFOR
BROWSE NOMODIFY NOCAPTIONS 

SELECT _tempm
COPY STRUCTURE TO _tempFill
locate				

*!*	SET STEP ON 
lcTranslatethis=_tempm.tekst1 
? lcTranslatethis


lcTranslatethisStep1=STRTRAN(lcTranslatethis,"<#","<#fff([_temp],[")
lcTranslatethisStep1=STRTRAN(lcTranslatethisStep1,"#>","])#>")

?lcTranslatethisStep1

oldexact=SET("Exact" )
SET EXACT ON 

lcTranslated=TEXTMERGE(lcTranslatethisStep1,.T.,"<#","#>")

SET EXACT &oldexact

?lcTranslated

INSERT INTO _tempFill VALUES (lcTranslated)

SELECT _tempFill
BROWSE NOMODIFY NOCAPTIONS 



FUNCTION fff(ali,tcTekst1)
LOCAL lcResult
=SEEK(tctekst1,ali)
lcResult = IIF(FOUND(ali),ALLTRIM(&ali..tekst),"???"+ALLTRIM(tcTekst1)+"???")
RETURN lcResult
ENDFUNC
BTW, I think the way to go is Textmerge(). With Textmerge, all these lines would be treated equal:
First line : <<#m._str1#>>
First line : <<# m._str1 #>>
First line : <<# m._Str1 #>>
First line : <<# m._STR1 #>>
First line : <<#      m._str1#>>
First line : <<#m._str1       #>>
PS: StrExtract() has nOccurence and nFlags parameters. Don't forget to return with delimiters if you use it.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform