OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

inadmissible value or data type error

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
cmosentine
General User
General User


Joined: 11 Sep 2003
Posts: 35

PostPosted: Tue Aug 29, 2006 11:34 am    Post subject: inadmissible value or data type error Reply with quote

Hello all: I am updating an older OOo 1.1x macro for use in OOo 2.0.3 The macro basic is going to be used to convert about 45,000 OOo 1.x documents (.sxw) to OOo 2.x (.odt) file format.

The macro is designed to transverse thru a series of directories, numbers 1,2,3 ...) and open the files within which are numbered 0 thru 999.

The macro works fine on a limited number of files but when I try to run it on an entire directory of files (999 files) it fails with "inadmissible value or data type". The line of code which gets flagged is a simple interger multipication and addition formula.

Since the macro ran fine for the first 508 files I am thinking the problem may be a file handle issue of some kind.

Has anyone alse seen this problem and solved it?? How??

All help greatly appreciated, Chris.
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Tue Aug 29, 2006 1:33 pm    Post subject: Re: inadmissible value or data type error Reply with quote

cmosentine wrote:
Since the macro ran fine for the first 508 files I am thinking the problem may be a file handle issue of some kind.

Regarding huge batch (conversion) jobs OOo stumbles from time to time. This has been reported manifold in this forum. Isn't it possible for you to continue with 509th document? I cannot image that you can convert 45,000 documents without restarting OOo.

With kind regards
hol.sten
Back to top
View user's profile Send private message
cmosentine
General User
General User


Joined: 11 Sep 2003
Posts: 35

PostPosted: Wed Aug 30, 2006 4:52 am    Post subject: Reply with quote

Yes I can certainly do that, but that is a bastardized way of working. I have used similar techniques when we converted from word perfect to staroffice format and twice since to replace built-in letterhead in the header and footer. In these cases SO and OOo did stumble but only after about 2000 + files, and then it was a lack of memory/resources.

But now the error is different in my opinion. The failure takes place during an integer operation. Surely OOo can handle 1000's of simple integer calcs. Or is this a result of memory/resource depletion, but in manifesting itself in a different form??

Chris
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Wed Aug 30, 2006 7:08 am    Post subject: Re: inadmissible value or data type error Reply with quote

cmosentine wrote:
when I try to run it on an entire directory of files (999 files) it fails with "inadmissible value or data type". The line of code which gets flagged is a simple interger multipication and addition formula.

Without a significant part of your code we can't help you.
It seems you create an overflow on a variable. Remember integer variables are 16 bits wide Wink
Back to top
View user's profile Send private message Visit poster's website
cmosentine
General User
General User


Joined: 11 Sep 2003
Posts: 35

PostPosted: Wed Aug 30, 2006 7:16 am    Post subject: Reply with quote

Below is a snippet of my macro code. I was able to fix the issue by using type double rather than integer.

Given an integer is 16 bits wide, it should not fail until an integer variable passes 65535. Now it's been a long time since school, but the code should work with type integer too!

Sub ConvertFileType

dim mNoArgs()
dim oDesktop, oDocument, oText, oTextCursor as Object
dim oStyleFamilies, oStyle, oPageStyles as Object
dim sTemplateURI, sPageStyleName as String
dim sURL, sPath, sExtension as String
dim dURL, dPath, dExtension as String
dim iCounter, jCounter, fileNumber as double

sTemplateURL = "file:///j:/oo/templates/vra/letterhead_vra.ott"

sPath = "file:///d:/so/pts/"
sExtension = "sxw"

dPath = "file:///d:/oo/pts/"
dExtension = "odt"

fileNumber = 0

' Create a desktop to work in
oDesktop = createUnoService("com.sun.star.frame.Desktop")

for iCounter = 32 to 32
for jCounter = 0 to 999

fileNumber = iCounter*1000+jCounter

' Generate the source file URL
sURL = sPath & iCounter & "/" & fileNumber & "." & sExtension

if FileExists(sURL) then

' File exists so open it up
oDocument = oDesktop.loadComponentFromURL(sURL, "_blank", 0, mNoArgs())
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Wed Aug 30, 2006 11:52 am    Post subject: Reply with quote

Basic Integer is 16bits signed. Range is from -32768 to +32767.
The code should work with Long variables (32 bits signed).
Back to top
View user's profile Send private message Visit poster's website
cmosentine
General User
General User


Joined: 11 Sep 2003
Posts: 35

PostPosted: Thu Aug 31, 2006 3:26 am    Post subject: Reply with quote

I am so stupid. YOU ARE EXACTLY RIGHT. Thanks for pointing out how much I have forgotten since CS101.

Thank you very much, Chris.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group