charles61 wrote:

I have a standalone consisting of a splash stack and an app stack. I have set
up a script that the user can insert some information into two tables - one
for students and one for adults. These tables are on two different cards in
my app stack.

I have been testing my standalone on Windows XP where it was installed in
the AllUsersAppData directory using an installer program.  I tried the
following script for the card that has the student list:

on closeCard
   Save "School Report" as "\Documents and Settings\All Users\Application
Data"
end closeCard

But this does not save the data in the two tables!  Any suggestions would be
greatly appreciated!

When the unexpected happens, it's time for error-checking. One of the challenges of crafting apps is that when you're being diligent only about half your code will actually do what your app does, and the other half will be all the stuff you add to account for when things go wrong. :)

In Rev, most error conditions are reported in "the result" immediately after a command fails, and for I/O and other system-related tasks you may find an additional OS-supplied error code using the sysError function.

So to better understand what's happening there you may try adding that to your script.

Also, by hard-wiring your paths they won't work on international systems where the spelling may differ, and may not survive changes to the OS if MS changes the names of those folders in a future version.

The solution for that is Rev's specialFolderPath function. Rev provides a variety of constants you can pass to that function to get the path, and pretty much all OS constants provided by the OS vendor can be used as well -- Ken Ray's put together this comprehensive list:
<http://sonsothunder.com/devres/revolution/tips/file010.htm>

While Rev doesn't include a built-in constant for that, looking at Ken's list you can use the OS constant instead, which is "35".

If you want that to be cross-platform you can use Ken's list to get the Application Support constant for OS X, but for now here's your code modified with specialFolderPath and including the error check which will hopefully help diagnose the issue.

A ha! As I was rewriting your code I noticed that you're specifying only the folder and not the file name, so effectively you're asking Rev to try to turn the stack into a folder, which of course it can't do. The fix for that is included in this revision:

on closeCard
   Save "School Report" as (specialFolderPath(35)&"/School Report.rev")
   if the result is not empty then
      answer error "An error occurred while saving the report: "&cr&\
         the result & "("& sysError() &")"
    end if
end closeCard

Note that the ".rev" extension can be changed to anything else you feel might be appropriate for your app. Rev opens stacks based on their internal stucture, and a standalone is not required to use the .rev file name extension to work with stack files, allowing you to define your own document types.

If you want to use a custom file name extension you may want to check <http://filext.com/> to see if another program may be using it. That's not a comprehensive list (Microsoft doesn't maintain such an index), but it'll at least help avoid some of the more obvious conflicts.

--
 Richard Gaskin
 Fourth World
 Rev training and consulting: http://www.fourthworld.com
 Webzine for Rev developers: http://www.revjournal.com
 revJournal blog: http://revjournal.com/blog.irv
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to