Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

RTF fields

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    RTF fields

    I have a form with 2 RTF fields: toxintro and toxmemo
    I have written a script that executes when a button is pushed. It is supposed to copy the contents of toxintro to the toxmemo field.. then it concatenates the contents of a variable named toxtext to the same rtf field (toxmemo).

    The toxtext is copied correctly but the toxinto information is not being added.

    I think that my error is not reading the toxinto rtf data correctly into a variable then transferring this correctly to the toxmemo field.
    "insert_text_in_rtf_memo(tbl,MemoFieldName,alltrim(Topparent.toxintro.value),InsertPos,FontNameSizeAttrib,FontColor)" is not correct

    can someone please help me with this?

    #2
    Re: RTF fields

    OOPS... forgot to send script
    'Insert text into a RTF memo field: 'Toxmemo' in current window.
    Dim TextToInsert as c
    Dim FontNameSizeAttrib as c
    Dim InsertPos as n
    Dim FontColor as c
    'TextToInsert = a5_eval_expression("=Var->TypeTxtVar",local_variables())
    TextToInsert = ToxText
    FontNameSizeAttrib = "Arial,8"
    InsertPos = -1
    FontColor = "WinText"

    Dim TempObj as p
    dim readonly_flag as l
    'Get a pointer to the Object on the Form/Browse that has the RTF memo field.
    TempObj = obj(parentform.name(16)+":"+"Toxmemo")
    'Check if the RTF memo is readonly
    readonly_flag = TempObj.field.readonly
    if readonly_flag = .t. then
    ui_msg_box("Error","Cannot insert text into RTF Memo field '"+"Toxmemo"+"' because it is read-only",UI_STOP_SYMBOL)
    end
    else
    dim Tbl as p
    'Get a pointer to the table for the RTF memo field
    Tbl = tempobj.Field_Get().table_get()
    dim MemoFieldName as c
    'Get the name of the RTF memo field (note: the field name is not necessarily the same as the object name on the form/browse)
    MemoFieldName = tempobj.field_get().name_get()
    'delete current contents of rtf field
    tbl.change_begin()
    tbl.field_blank(MemoFieldName)
    'Call the insert_text_in_rtf_memo() function to insert the text into the RTF memo field.
    insert_text_in_rtf_memo(tbl,MemoFieldName,alltrim(Topparent.toxintro.value),InsertPos,FontNameSizeAttrib,FontColor)
    insert_text_in_rtf_memo(Tbl,MemoFieldName,TextToInsert,InsertPos,FontNameSizeAttrib,FontColor)
    'Now activate the RTF memo, or else it will not show the newly inserted text
    tempobj.activate()
    'now set the insertion point after the text just entered (tempobj.topparent gets a pointer to the form in which the object is contained)
    if InsertPos = -1 then 'inserting at end of field
    tempobj.topparent.cursor_set(9999999)
    else
    tempobj.topparent.cursor_set(InsertPos + len(TextToInsert))
    end if
    end if
    tbl.change_end(.t.)

    'Disallow editing of records in current form at parent level.
    topparent.allow_change(.f.)
    parentform.Refresh_Layout()
    'tbl.change_end(.t.)
    'parentform.resynch()

    Comment


      #3
      Re: RTF fields

      Hi David,

      I have not been through your code but here is mine which works perfectly.

      I have the first line Approved.text="T" to prevent more than one user on the network opening the form for the same job number at the same time. Note that the Value is set to .F. at the end. Also note that I have the Date and Time plus the Initials of the User. This is from my own UDF. Let me know if you would like that too.
      Code:
      topparent:Approved.Text="T"
      
      constant separator=chr(13)+chr(10)
      
      topparent.commit()
      dim ft1 as p
      ft1=topparent:free_text1_rtf.this
      ft2=topparent:free_text2_rtf.this
      ft1.rtf.set_cursor(1)
      ft1.rtf.insert_text(separator+initials()+" "+dtoc(date())+" "+time("0h:0m")+crlf())
      ft1.activate()
      xbasic_wait_for_idle()
      textlen=len(ft1.rtf.plain_text)
      ft1.rtf.set_cursor(textlen+1)
      ft1.rtf.insert_text(crlf())
      xbasic_wait_for_idle()
      ft1.textselect(1,-1)
      ft1.rtf.cut()
      
      ft2.field.read
      ft2.activate()
      ft2.rtf.set_cursor(1)
      ft2.rtf.paste()
      
      topparent:approved.Value=.F.
       
       ft2.field.read
       topparent.commit()
       sys_send_keys("{F9}")
      Good luck.
      Regards
      Keith Hubert
      Alpha Guild Member
      London.
      KHDB Management Systems
      Skype = keith.hubert


      For your day-to-day Needs, you Need an Alpha Database!

      Comment


        #4
        Re: RTF fields

        Thanks Keith...
        i'm not sure that i follow your script..
        all i want to do is copy Rich Text from one RTF field on my form to another RTF field on the same form... after 1st deleting the contents of the RTF field that i am copying to.

        how can i do this?
        does your script do this?

        Comment


          #5
          Re: RTF fields

          Hi David,

          My script allows the user to enter text into one RTF and add it to the Text in the second RTF field, and then delete the text from the first RTF so that it is now an empty field for the next user to add text into the record.

          The second RTF is always read only, to prevent the user from editing past text. That is the point of the Date and Time stamp.

          Are you wanting to delete the text from the second RTF and replace it with the new text just entered into the first RTF?
          Regards
          Keith Hubert
          Alpha Guild Member
          London.
          KHDB Management Systems
          Skype = keith.hubert


          For your day-to-day Needs, you Need an Alpha Database!

          Comment


            #6
            Re: RTF fields

            sort of...

            the rtf text in the 1st field is populated from a table and the actual value depends on conditions in the form that i am working on. The user can only change the value in the 1st rtf field indirectly. User changes a numeric value in a field and the text inn the 1st RTF field changes... (looked up in a table). If the user is happy with the text in the 1st rtf field they click a button and the rtf text in the second rtf field should be deleted and the rtf text from the 1st rtf field should be copied to the 2nd RTF field.

            BUT i can't seem to figure out how to do a simple copy of the RTF text from one field to another???!!! it CAN'T be that difficult.

            any help would be MUCH appreciated.

            Comment


              #7
              Re: RTF fields

              Hi David,

              You are right it is not that difficult.

              Write down each step that you want done.

              With the use of variables and conditions you can do just what you want.

              Try and accomplish each step before you do the next one. It will make life a lot easier, than trying to do it all in one go.
              Regards
              Keith Hubert
              Alpha Guild Member
              London.
              KHDB Management Systems
              Skype = keith.hubert


              For your day-to-day Needs, you Need an Alpha Database!

              Comment


                #8
                Re: RTF fields

                Originally posted by David Boomer View Post
                BUT i can't seem to figure out how to do a simple copy of the RTF text from one field to another???!!! it CAN'T be that difficult.
                Check out (if you need to do something with the text before copying.)

                RTF_Text as C = *BIN_TO_RTF( RTF_Binary_Text as B ) 'reads an rtf memo field

                and

                RTF_Binary_Text as B = *RTF_TO_BIN( RTF_Text as C ) 'stores rtf in an rtf memo field.

                If you don't

                Code:
                tbl = table.open("yourtablename")
                tbl.change_begin()
                tbl.[COLOR="red"]destination[/COLOR] = tbl.[COLOR="Red"]source [/COLOR]'use your rtf memo field names
                tbl.change_end(.t.)
                tbl.close()
                If the table is already open you would use a different method to get the tbl pointer and you wouldn't close with the last statement.
                There can be only one.

                Comment


                  #9
                  Re: RTF fields

                  Hi Keith
                  ... i thought that that was what i was doing...

                  Step 1) blank the rtf field that will receive the data
                  Step 2) place the info in the blanked field...

                  Here is the code that i hoped would do this:

                  MemoFieldName = tempobj.field_get().name_get()
                  'delete current contents of rtf field
                  tbl.change_begin()
                  tbl.field_blank(MemoFieldName)
                  'Call the insert_text_in_rtf_memo() function to insert the text into the RTF memo field.
                  insert_text_in_rtf_memo(tbl,MemoFieldName,alltrim(Topparent.toxintro.value),InsertPos,FontNameSizeAttrib,FontColor)
                  insert_text_in_rtf_memo(Tbl,MemoFieldName,TextToInsert,InsertPos,FontNameSizeAttrib,FontColor)


                  (see my 1st post)

                  didn't work... don't know why...

                  Comment


                    #10
                    Re: RTF fields

                    Try changing to

                    Code:
                    insert_text_in_rtf_memo(tbl,MemoFieldName,alltrim(Topparent.toxintro.[COLOR="Red"][B]text[/B][/COLOR]),InsertPos,FontNameSizeAttrib,FontColor)
                    This insert function expects text as the third parameter. The datatype of the form objectname.value is binary.

                    Ignore my earlier post, didn't start at the first to see where the thread had gone.
                    There can be only one.

                    Comment


                      #11
                      Re: RTF fields

                      This is the main part of the code which Cuts the text from first RTF and Pastes it into the second RTF.
                      Code:
                      [COLOR="Red"]ft1.rtf.cut[/COLOR]()
                      ft2.field.read
                      ft2.activate()
                      ft2.rtf.set_cursor(1)  ' This sets the entry point at the begining of the RTF
                      [COLOR="red"]ft2.rtf.paste()[/COLOR]
                      Regards
                      Keith Hubert
                      Alpha Guild Member
                      London.
                      KHDB Management Systems
                      Skype = keith.hubert


                      For your day-to-day Needs, you Need an Alpha Database!

                      Comment


                        #12
                        Re: RTF fields

                        Stan & Keith
                        THANKS
                        I am definitely getting closer! I can copy the field & past the data... sort of:
                        The following code:
                        dim Tbl as p
                        'Get a pointer to the table for the RTF memo field
                        Tbl = tempobj.Field_Get().table_get()
                        dim MemoFieldName as c
                        'Get the name of the RTF memo field (note: the field name is not necessarily the same as the object name on the form/browse)
                        MemoFieldName = tempobj.field_get().name_get()
                        'delete current contents of rtf field
                        tbl.change_begin()
                        tbl.field_blank(MemoFieldName)
                        ToxIntroRTF = *BIN_TO_RTF(Topparent.toxintro)
                        'TextToInsert = *RTF_TO_BIN(ToxintroRTF)
                        'RTF_Binary_Text as B = *RTF_TO_BIN(RTF_Text)
                        'Call the insert_text_in_rtf_memo() function to insert the text into the RTF memo field.
                        'insert_text_in_rtf_memo(tbl,MemoFieldName,Topparent.toxintro.value,InsertPos,FontNameSizeAttrib,FontColor)
                        insert_text_in_rtf_memo(Tbl,MemoFieldName,ToxIntroRTF,InsertPos,FontNameSizeAttrib,FontColor)
                        'Now activate the RTF memo, or else it will not show the newly inserted text
                        tempobj.activate()
                        'now set the insertion point after the text just entered (tempobj.topparent gets a pointer to the form in which the object is contained)
                        if InsertPos = -1 then 'inserting at end of field
                        tempobj.topparent.cursor_set(9999999)
                        else
                        tempobj.topparent.cursor_set(InsertPos + len(TextToInsert))
                        end if
                        end if
                        tbl.change_end(.t.)

                        results in the field being populated with:
                        {\rtf1\ansi \deff0{\colortbl;\red0\green0\blue0;}{\fonttbl{\f0\fswiss Tahoma;}}{{\f0 \cf1 \fs16 These elements are very good indicators of exposure and impaired physiological function. Mercury, Cadmium and Lead are particularly relevant in this regard. Thallium is also toxic and hair level is a... etc

                        SO...
                        how do i convert ToxIntroRTF ??

                        *RTF_TO_BIN(ToxIntroRTF) results in a blank field.

                        Comment


                          #13
                          Re: RTF fields

                          Hi David,

                          Any chance of the app with some sample data to play with.

                          I'm sure we can get a faster result for you this way. With some instructions as to what the process should be.
                          Regards
                          Keith Hubert
                          Alpha Guild Member
                          London.
                          KHDB Management Systems
                          Skype = keith.hubert


                          For your day-to-day Needs, you Need an Alpha Database!

                          Comment


                            #14
                            Re: RTF fields

                            Keith... i will try to disentanle the proprietary info & send you a version... in the meantime;
                            i am making progress !!!

                            The following code does (almost) exactly what i want:

                            dim Tbl as p
                            dim ToxIntroRTF As B

                            Tbl = tempobj.Field_Get().table_get()
                            dim MemoFieldName as c
                            MemoFieldName = tempobj.field_get().name_get()
                            tbl.change_begin()
                            tbl.field_blank(MemoFieldName)
                            ToxIntroRTF = Topparent.toxintro
                            TextToInsert = RTF_TO_TEXT(ToxintroRTF)
                            insert_text_in_rtf_memo(Tbl,MemoFieldName,TextToInsert,InsertPos,FontNameSizeAttrib,FontColor)
                            end if
                            tbl.change_end(.t.)

                            ... the contents of the toxintro rtf filed are successfully transferred to the toxmemo rtf field !!! yeah!!!

                            BUT the formating (Bold Underline etc) is not transferred.

                            I'm sure that the problem is with how i am initiallizing the blob variable or how i am writing the blob variable to the toxmemo rtf field..

                            I am probably making stupid mistakes (i've been working on this for MANY hours!!) but i just can't wrap my mind around the rtf object/field xbasic.

                            ... as always, suggestions are much appreciated.

                            Comment


                              #15
                              Re: RTF fields

                              Hi David,

                              Have you tried the paste() function?

                              I think the insert_text_in_rtf_memo() only copies in the text without the formatting.

                              I did work on this for sometime myself and got some great help from Dr Peter Wayne, so I know what I have works very well.
                              Regards
                              Keith Hubert
                              Alpha Guild Member
                              London.
                              KHDB Management Systems
                              Skype = keith.hubert


                              For your day-to-day Needs, you Need an Alpha Database!

                              Comment

                              Working...
                              X