Solved

LibraryExport() for long script

Posted on 2003-12-09
10
375 Views
Last Modified: 2013-12-26
I used LibraryExport() to export a Window object in PB5.
But the object is too large that it can only export partially.

How can I fix the problem if I want to use  script instead of the Export Painter
to export objects?
0
Comment
Question by:xo123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9917502
Are you using PB 5.0 16 bit? Migrate to 32bit PB 5.0 then LibraryExport will work for string length greater than 64K.

16 bit string datatype can only hold 64K.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9917504
Btw, this is not PB limitation, but OS limitation.
0
 

Author Comment

by:xo123
ID: 9917588
I think I'm using 32bit.
This is the info from 'About'
    PowerBuilder Enterprise/32
           by Powersoft
       Version 5.0.04
  Copyright c 1991 - 1997 Sybase, Inc.
       and its subsidiaries.
.....
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9917617
Does the string gets truncated when you run the app thru development environment as well? What operating system you are using?

0
 

Author Comment

by:xo123
ID: 9917650
For any objects longer than 32 KB,
the libaryexport() can only export them to 32 KB long.
But if I used the Library painter's Export option, it can export successfully without loss.

Here's my coding:
   ....
   String  ls_objsyn
   ls_objsyn = LibraryExport( lib_path,  obj_name, DirWindow! )
   ....

0
 

Author Comment

by:xo123
ID: 9917653
I'm using Window 2000 Professional.
0
 

Author Comment

by:xo123
ID: 9917682
Oh.... I just discover one thing:
  FileWrite can write only 32,766 bytes at a time, which includes the string   terminator character. If the length of variable exceeds 32,765, FileWrite writes the first 32,765 characters and returns 32,765.

I'm using FileWrite() for writing the export script.

What can I do?
0
 

Author Comment

by:xo123
ID: 9917695
I'll try to partition the export script (ls_objsyn) and write each partition at a time.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9917697
OK. Using filewrite you can only write 32k at a time. Try PFCs of_FileWrite. I think of_filewrite can handle more than 32K.
0
 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 50 total points
ID: 9917725
Here is the PFCs FileWrite

//////////////////////////////////////////////////////////////////////////////
//
//      Function:  of_FileWrite
//
//      Access:  public
//
//      Arguments:
//      as_FileName                        The name of the file to write to.
//      as_Text                                    The text to be written to the file.
//      ab_Append                        True - append to the end of the file,
//                                                      False - overwrite the existing file.
//
//      Returns:            Integer
//                              1 if successful, -1 if an error occurrs.
//
//      Description:      Open, write to, and close a file.  Handles strings > 32,765 bytes.
//
//////////////////////////////////////////////////////////////////////////////
//
//      Revision History
//
//      Version
//      5.0   Initial version
//      6.0.01      Rewrite to handle strings > 60k making more than 2 passes (for 32 bit platforms)
//
//////////////////////////////////////////////////////////////////////////////
//
//      Copyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.
//      Any distribution of the PowerBuilder Foundation Classes (PFC)
//      source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Integer            li_FileNo, li_writes, li_cnt
Long                  ll_StrLen, ll_currentpos
String            ls_Text
Writemode      lwm_Mode

If ab_Append Then
      lwm_Mode = Append!
Else
      lwm_Mode = Replace!
End if

li_FileNo = FileOpen(as_FileName, StreamMode!, Write!, LockReadWrite!, lwm_Mode)
If li_FileNo < 0 Then Return -1

ll_StrLen = Len(as_Text)

// If the string is longer than 32765 bytes then it will require multiple writes to write it
If ll_StrLen > 32765 Then
      If Mod(ll_StrLen, 32765) = 0 Then
            li_Writes = ll_StrLen / 32765
      Else
            li_Writes = (ll_StrLen / 32765) + 1
      End if
Else
      li_Writes = 1
End if

ll_CurrentPos = 1

For li_Cnt = 1 To li_Writes
      ls_Text = Mid(as_Text, ll_CurrentPos, 32765)
      ll_CurrentPos += 32765
      If FileWrite(li_FileNo, ls_Text) = -1 Then
            Return -1
      End if
Next

FileClose(li_FileNo)

Return 1
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question