Back to getting vServer Office to execute in LiveCode Server Scripts on my IIS 5.1 web server

Mike Bonner bonnmike at gmail.com
Fri Mar 9 08:41:42 CST 2012


*sigh* Yep. that sleep thing. This script works fine but will throw a
server error because if there are no errors it doesn't actually SAY
anything so no content is sent back. (and I forgot to put () on the end of
the last showError())
Just make sure you put some content on the page to avoid a 500 internal
server error.

Sorry for all the spam this morning everyone.

On Fri, Mar 9, 2012 at 7:39 AM, Mike Bonner <bonnmike at gmail.com> wrote:

> Ok this one. (for vserver only using lc server)
>
> Same as mentioned, declare the commands and functions first, seems more
> reliable, and then, removed the gclient of this stack check removed the
> portion for else, and left the code for gclient of this stack = true and am
> working again.
>
>
> <?lc
> local mDatabase,mConn
>
> on DatabaseCreate
>     put VConnection_Constructor( "localhost", "sa", "sa") into mConn
>     get VConnection_Open( mConn )
>     get ShowError()
>     put VDatabase_Constructor( mConn ) into mDatabase
>
>   get VDatabase_Open( mDatabase, "database1" )
>    get ShowError()
>    if VDatabase_ErrNumber( mDatabase ) is not "0" then
>     if VDatabase_ErrNumber( mDatabase ) is not "532480" then
>       get VDatabase_Create( mDatabase, "Database1", "kDscDatBlbInd" )
>       get showError()
>       CreateStructure
>     else
>       answer VDatabase_ErrString( mDatabase )
>       close the defaultStack
>     end if
>   end if
>
>   put VDatabase_Table( mDatabase, "Person" ) into mPerson
>   put VTable_Field( mPerson, "FirstName" )  into mFirstName
>   put VTable_Field( mPerson, "LastName" )  into mLastName
>   put VTable_Field( mPerson, "BirthDate" )  into mBirthDate
>
> end DatabaseCreate
>
> on DatabaseClose
>     get VDatabase_Close( mDatabase )
>     put VDatabase_Destructor( mDatabase ) into mDatabase
> end DatabaseClose
>
> on CreateStructure
>    put VDatabase_CreateTable(mDatabase, "Person") into pTable
>
>    get VTable_CreateVarcharField( pTable, "Name", 1022, "fIndexed" )
>    get VTable_CreateVarcharField( pTable, "LName", 1022, "fIndexed" )
>    get VTable_CreateDateField( pTable, "BirthDate", "fIndexed" )
> end CreateStructure
>
> function ShowError
>   put Valentina_ErrNumber() into errCode
>   put Valentina_ErrString() into errString
>
>   if errCode <> 0 then
>     show message box
>     put errString into message
>   end if
> end ShowError
>
>    -- this section would be in opencard in a stack
>    get valentina_initclient()
>    get showError()
>    databasecreate
>
> -- this section would be in closecard in a stack
>    databaseClose
>    get valentina_shutdown
>    get showError
> ?>
>
> On Fri, Mar 9, 2012 at 7:31 AM, Mike Bonner <bonnmike at gmail.com> wrote:
>
>> Ok, so thats the wrong one too. *cough*  Somebody needs more sleep!  Will
>> get bck to a full working revision and post it once I have the thing solid
>> again.
>>
>> (for 1, you can't really check the gclient of the stack like I show in
>> the script) DOH
>>
>>
>> On Fri, Mar 9, 2012 at 7:15 AM, Mike Bonner <bonnmike at gmail.com> wrote:
>>
>>> I've been messing around so much I don't recall which version of the
>>> livecode-server script I sent you.  Looking at the one you posted I think I
>>> sent the wrong one!
>>>
>>> The order is wrong, you'll want to declare all the commands and
>>> functions FIRST and then actually call them, otherwise they don't yet exist
>>> in memory yet and this can cause issues. (at least so it seems to me.
>>>
>>> The revised script is here. It doesn't do much, just tries to connect,
>>> determines if the open failed, if it did, creates the db and structure
>>> instead, then closes itself out.
>>>
>>>
>>> --declare all handlers first
>>> on DatabaseCreate
>>> if the gClient of this stack is true then
>>>     put VConnection_Constructor( "localhost", "sa", "sa") into mConn
>>>     get VConnection_Open( mConn )
>>>    get ShowError()
>>>     put VDatabase_Constructor( mConn ) into mDatabase
>>>   else
>>>     put VDatabase_Constructor() into mDatabase
>>>   end if
>>>
>>>   get VDatabase_Open( mDatabase, "database1" )
>>>    get ShowError()
>>>   if VDatabase_ErrNumber( mDatabase ) is not "0" then
>>>     if VDatabase_ErrNumber( mDatabase ) is not "532480" then
>>>       get VDatabase_Create( mDatabase, "Database1", "kDscDatBlbInd" )
>>>       get showError()
>>>       CreateStructure
>>>     else
>>>       answer VDatabase_ErrString( mDatabase )
>>>       close the defaultStack
>>>     end if
>>>   end if
>>>
>>>   put VDatabase_Table( mDatabase, "Person" ) into mPerson
>>>   put VTable_Field( mPerson, "FirstName" )  into mFirstName
>>>   put VTable_Field( mPerson, "LastName" )  into mLastName
>>>   put VTable_Field( mPerson, "BirthDate" )  into mBirthDate
>>>
>>> end DatabaseCreate
>>>
>>>
>>> on DatabaseClose
>>>     get VDatabase_Close( mDatabase )
>>>     put VDatabase_Destructor( mDatabase ) into mDatabase
>>> end DatabaseClose
>>>
>>> on CreateStructure
>>>    put VDatabase_CreateTable(mDatabase, "Person") into pTable
>>>
>>>    get VTable_CreateVarcharField( pTable, "Name", 1022, "fIndexed" )
>>>    get VTable_CreateVarcharField( pTable, "LName", 1022, "fIndexed" )
>>>    get VTable_CreateDateField( pTable, "BirthDate", "fIndexed" )
>>> end CreateStructure
>>>
>>> function ShowError
>>>   put Valentina_ErrNumber() into errCode
>>>    put Valentina_ErrString() into errString
>>>
>>>   if errCode <> 0 then
>>>     show message box
>>>     put errString into message
>>>   end if
>>> end ShowError
>>>
>>> -- then go through the steps.  init, then check for error (using the
>>> showError function)
>>>    get valentina_initclient()
>>>    get showError()
>>>
>>> -- call the databasecreate handler
>>>    databasecreate
>>> -- a curiosity check of the current contents of mDatabase && mConn
>>> -- could do a showError here also
>>>    put mDatabase && mConn
>>>
>>> -- call the databaseclose handler and shutdown, then put the result of
>>> the shutdown. (should be 0)
>>>    databaseClose
>>>    get valentina_shutdown
>>>    put it && the result
>>> -- I think I mentioned, but I have vserver running in manual mode from
>>> the
>>> --command line so I can watch the connection establish do its thing
>>> -- and disconnect, live on the console.
>>> ?>
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macserve.net/pipermail/valentina/attachments/20120309/9374869d/attachment-0001.html>


More information about the Valentina mailing list