Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   Tools Development (http://www.baanboard.com/baanboard/forumdisplay.php?f=8)
-   -   How to use text.write() function (http://www.baanboard.com/baanboard/showthread.php?t=69704)

showstuff11 27th January 2017 05:01

How to use text.write() function
 
Good morning,

can i call for a help on how to use this text.write function,
i cannot really understand on how to use this code..
ths is from another post here in baanboard
http://www.baanboard.com/baanboard/s...ead.php?t=9968

t.no = text.write( "tdsls040.txtb", "2", kw1,kw2, kw3, kw4, "text", "text", tmp.file )

this is the condition im facing... a header remarks with 2 to more line of text

please help me understand this function..

bdittmar 27th January 2017 08:58

text.write()
 
Hello,
Code:

text.write()
Syntax:

function long  text.write  (string text_field, string lang, string kw1, string kw2, string kw3, string kw4, string tgroup, string edit_opt, string tmp_file [, long bidi] [, string rtf_file])

Description


This adds a new text to the text manager and assigns a new text number to the text.


Arguments

string text_field The name of the new text field. See Text fields overview. This returns the text number for the new field.
 
string lang This specifies the language for the new text.
 
string kw1 Use these arguments to specify key words for the text.
 
string kw2 
string kw3 
string kw4 
string tgroup This specifies the name of the text group to which the text must be assigned. If you specify an empty string here, the text is assigned to the user's default group.
 
string edit_opt This specifies the type of window in which the text must be displayed.
 
string tmp_file The name of the file where the text for the new field is stored. The contents of this file is changed before the text is stored, Long lines are wrapped to meet the line width of the text group to which the text is assigned.
 
[long bidi ] Use this optional argument to indicate the text alignment. Possible values are:

true      text is right justified

false    text is left justified; this is the default option
 
[string rtf_file ] The name of the file in which the RTF version of the text must be stored. This is an optional argument. The usage of this argument depends on the settings of the text group as defined in the tgroup argument. If this is an empty string, no text is retrieved and the function returns 0.
 
 
Return values

>0        success; returns the number of lines written

 <0        error

Include bic_text :
Code:

#include <bic_text>
           

void
            remove.textfields() ( const string field.name.string, ... )

void
            set.file.for.textfield() ( const string field.name.string, const string filename )

long
            text.copy() ( string text_field_to(17),  string text_field_from(17),  string kw1(17) mb, string kw2(17) mb,  string kw3(17) mb, string kw4(17) mb,  string tgroup(8), string edit_opt(15) )

long
            text.copy.between.companies() ( string text_field_to(17),  string text_field_from(17),  long source_company,  long target_company, string kw1(17) mb,  string kw2(17) mb, string kw3(17) mb,  string kw4(17) mb, string tgroup(8),  string edit_opt(15) )

long
            text.copy.language() ( long textnr, string lang_from,  string lang_to )

long
            text.defaults() ( string text_field(17),  ref string tgroup(8),  ref string edit_opt(15),  [long comp_number] )

long
            text.delete() ( string text_field(17), string lang )

long
            text.edit() ( string text_field(17), string lang, string kw1(17) mb, string kw2(17) mb, string kw3(17) mb, string kw4(17) mb, string tgroup(8), string edit_opt(15),  long mode )

long
            text.present.in.language() ( long textnr, string lang  [, ref long nr_lines ] )

long
            text.read() ( string text_field(17), string lang,  ref string kw1(17) mb,  ref string kw2(17) mb,  ref string kw3(17) mb,  ref string kw4(17) mb,  ref string tgroup(8),  ref string edit_opt(15),  string tmp_file(256), long lock [,string rtf_file(256)] )

long
            text.rewrite() ( string text_field(17), string lang,  string kw1(17) mb, string kw2(17) mb, string kw3(17) mb, string kw4(17) mb, string tgroup(8), string edit_opt(15),  string tmp_file(256) [, long bidi, string rtf_file(256)] )

long
            text.to.buf() ( string text_field(17), string lang,  long nr_lines,  ref string buf(,)  [, long rtf.text] )

boolean
            text.buf.to.field() ( string text_field(17), string buf )

boolean
            text.set.keywords() ( string text_field(17), string kw1(17),  [, string kw2(17),  string kw3(17),  , long kw4(17)] )

boolean
            text.set.language() ( string text_field(17), string language(1))

long
            textfield.to.database() ( string text_field(17) )

long
            textfield.to.buf() ( string text_field(17), ref string buffer )

long
            text.window() ( string edit_opt(15),  ref long start_column,  ref long start_row,  ref long number_columns,  ref long number_rows )

long
            text.write() ( string text_field(17), string lang, string kw1(17) mb, string kw2(17) mb, string kw3(17) mb, string kw4(17) mb,  string tgroup(8), string edit_opt(15),  string tmp_file(256) [, long bidi, string rtf_file(256)] )

Regards

alex.bonutti 4th September 2017 12:12

Hi all,
I'm developing a session extension with Tools 10.5 which should create and save a predefined text in purchase order footer. I've tried both via external variable or via database text field, text is created but I'm not able to commit the transaction and save it. This is a sample of my 4GL code:

...
file.tmp = creat.tmp.file$()
ft = seq.open(file.tmp,"w")

text_body = "Sample text"
ret = seq.puts(text_body, ft)
seq.close(ft)

ret = text.write("tdpur400.txtb", "6", "Purchase.", "Order footer.", tdpur400.orno, "", "text", "text", file.tmp)

ret = dal.change.object("tdpur400")
ret = dal.save.object("tdpur400")
if ret <> 0 then
abort.transaction()
ret = dal.get.error.message(error.mess)
message(str$(ret) & " - " & error.mess)
else
commit.transaction()
message("Footer text created for purchase order " & tdpur400.orno)
endif
...

dal.get.error.message return value is 1.
I made a few tries with DAL scripts

ret = dal.change.object("tdpur400")
dal.set.field("tdpur400.txtb", text_nr)
ret = dal.save.object("tdpur400")


or even db update funtions

db.update(ttdpur400, db.retry)

but transaction cannot be completed with DAL error

Record ... cannot be saved in table Purchase Orders in company ...

If I commit just the text.write function, a text is correctly saved in the database, but it can't be linked in my entity (which is a purchase order). Can someone help me?

Thanks,
Alex


All times are GMT +2. The time now is 15:51.


vB.Sponsors
©2001-2017 - Baanboard.com - Baanforums.com