*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())<div>
Just make sure you put some content on the page to avoid a 500 internal server error. </div><div><br></div><div>Sorry for all the spam this morning everyone. <br><br><div class="gmail_quote">On Fri, Mar 9, 2012 at 7:39 AM, Mike Bonner <span dir="ltr"><<a href="mailto:bonnmike@gmail.com">bonnmike@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok this one. (for vserver only using lc server)<div><br></div><div>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. </div>
<div><br></div><div><br></div><div><div><?lc</div><div>local mDatabase,mConn</div><div><br></div><div>on DatabaseCreate</div><div class="im"><div> put VConnection_Constructor( "localhost", "sa", "sa") into mConn</div>
<div> get VConnection_Open( mConn )</div><div> get ShowError() </div><div> put VDatabase_Constructor( mConn ) into mDatabase</div><div> </div></div><div><div class="h5"><div> get VDatabase_Open( mDatabase, "database1" )</div>
<div>
get ShowError() </div><div> if VDatabase_ErrNumber( mDatabase ) is not "0" then</div><div> if VDatabase_ErrNumber( mDatabase ) is not "532480" then </div><div> get VDatabase_Create( mDatabase, "Database1", "kDscDatBlbInd" )</div>
<div> get showError()</div><div> CreateStructure</div><div> else</div><div> answer VDatabase_ErrString( mDatabase )</div><div> close the defaultStack</div><div> end if</div><div> end if</div><div>
</div><div> put VDatabase_Table( mDatabase, "Person" ) into mPerson</div><div> put VTable_Field( mPerson, "FirstName" ) into mFirstName</div><div> put VTable_Field( mPerson, "LastName" ) into mLastName</div>
<div> put VTable_Field( mPerson, "BirthDate" ) into mBirthDate</div><div><br></div><div>end DatabaseCreate</div><div><br></div><div>on DatabaseClose</div><div> get VDatabase_Close( mDatabase )</div><div> put VDatabase_Destructor( mDatabase ) into mDatabase</div>
<div>end DatabaseClose</div><div><br></div><div>on CreateStructure</div><div> put VDatabase_CreateTable(mDatabase, "Person") into pTable</div><div> </div><div> get VTable_CreateVarcharField( pTable, "Name", 1022, "fIndexed" )</div>
<div> get VTable_CreateVarcharField( pTable, "LName", 1022, "fIndexed" )</div><div> get VTable_CreateDateField( pTable, "BirthDate", "fIndexed" )</div><div>end CreateStructure</div>
<div><br></div><div>function ShowError</div><div> put Valentina_ErrNumber() into errCode</div><div> put Valentina_ErrString() into errString</div><div> </div><div> if errCode <> 0 then </div><div> show message box</div>
<div> put errString into message</div><div> end if</div><div>end ShowError</div><div><br></div></div></div><div> -- this section would be in opencard in a stack</div><div> get valentina_initclient()</div><div> get showError()</div>
<div> databasecreate</div><div><br></div><div>-- this section would be in closecard in a stack</div><div> databaseClose</div><div> get valentina_shutdown<span style="white-space:pre-wrap"> </span></div>
<div> get showError</div><div>?></div><div><div class="h5"><br><div class="gmail_quote">On Fri, Mar 9, 2012 at 7:31 AM, Mike Bonner <span dir="ltr"><<a href="mailto:bonnmike@gmail.com" target="_blank">bonnmike@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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. <div><br></div><div>(for 1, you can't really check the gclient of the stack like I show in the script) DOH<div>
<div><br>
<br><div class="gmail_quote">On Fri, Mar 9, 2012 at 7:15 AM, Mike Bonner <span dir="ltr"><<a href="mailto:bonnmike@gmail.com" target="_blank">bonnmike@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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! <div><br></div><div>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.</div>
<div><br></div><div>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. </div><div><br></div>
<div>
<br></div><div>--declare all handlers first</div><div><div>on DatabaseCreate</div><div>if the gClient of this stack is true then</div><div> put VConnection_Constructor( "localhost", "sa", "sa") into mConn</div>
<div> get VConnection_Open( mConn )</div><div> get ShowError()</div><div><div> put VDatabase_Constructor( mConn ) into mDatabase</div></div><div><div><div> else</div><div> put VDatabase_Constructor() into mDatabase</div>
<div> end if</div>
<div> </div><div> get VDatabase_Open( mDatabase, "database1" )</div><div> get ShowError()</div><div> if VDatabase_ErrNumber( mDatabase ) is not "0" then</div><div> if VDatabase_ErrNumber( mDatabase ) is not "532480" then </div>
<div> get VDatabase_Create( mDatabase, "Database1", "kDscDatBlbInd" )</div><div> get showError()</div><div> CreateStructure</div><div> else</div><div> answer VDatabase_ErrString( mDatabase )</div>
<div> close the defaultStack</div><div> end if</div><div> end if</div><div> </div><div> put VDatabase_Table( mDatabase, "Person" ) into mPerson</div><div> put VTable_Field( mPerson, "FirstName" ) into mFirstName</div>
<div> put VTable_Field( mPerson, "LastName" ) into mLastName</div><div> put VTable_Field( mPerson, "BirthDate" ) into mBirthDate</div><div><br></div><div>end DatabaseCreate</div><div><br></div><div>
<br></div><div>on DatabaseClose</div><div> get VDatabase_Close( mDatabase )</div><div> put VDatabase_Destructor( mDatabase ) into mDatabase</div><div>end DatabaseClose</div><div><br></div><div>on CreateStructure</div>
<div> put VDatabase_CreateTable(mDatabase, "Person") into pTable</div><div> </div><div> get VTable_CreateVarcharField( pTable, "Name", 1022, "fIndexed" )</div><div> get VTable_CreateVarcharField( pTable, "LName", 1022, "fIndexed" )</div>
<div> get VTable_CreateDateField( pTable, "BirthDate", "fIndexed" )</div><div>end CreateStructure</div><div><br></div><div>function ShowError</div><div> put Valentina_ErrNumber() into errCode</div>
<div>
put Valentina_ErrString() into errString</div><div> </div><div> if errCode <> 0 then </div><div> show message box</div><div> put errString into message</div><div> end if</div><div>end ShowError</div><div>
<br></div></div></div><div>-- then go through the steps. init, then check for error (using the showError function) </div><div> get valentina_initclient()</div><div> get showError()</div><div><br></div><div>-- call the databasecreate handler</div>
<div> databasecreate</div><div>-- a curiosity check of the current contents of mDatabase && mConn</div><div>-- could do a showError here also</div><div> put mDatabase && mConn</div><div><br></div><div>
-- call the databaseclose handler and shutdown, then put the result of the shutdown. (should be 0)</div><div> databaseClose</div><div><div> get valentina_shutdown<span style="white-space:pre-wrap"> </span></div>
<div> put it && the result</div></div><div>-- I think I mentioned, but I have vserver running in manual mode from the </div><div>--command line so I can watch the connection establish do its thing</div><div>-- and disconnect, live on the console. </div>
<div>?></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>