Source language: Translate to:

Pubdir when

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Pubdir when

Postby BRobinsonS » Wed Oct 02, 2013 2:05 pm

I created a new small app using DBPro which is not relevent to the question but..
When I ran it on another computer it came up with 'can't find file c:/somewhere/somefile '.
Thinking that I forgot to remove the path and replace it with [Pubdir] I checked it but I had replaced it.
Removed [Pubdir] and is worked without it.

I know there are times to keep the search in the 'Pubdir' using [Pubdir] variable but,just to clarify, when should it be used and when is it not necessary.
Is it used to Extract files from Neobook too?
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: Pubdir when

Postby dec » Wed Oct 02, 2013 2:45 pm

Hello,

If I'm not wrong, you can choose where to extract your embedded files. Just when need to extract a file you need to provide a target path in order to be extracted. Anyway you can use the "[PubDir]" anytime and probably is the best option you can choose. In fact it's a bad idea to use "static" paths in our software because we cannot know if other computers have these paths availables or not. Probably not. So we need to avoid this.

So the "[PubDir]" variable is the starting point for paths relatives to your executable's. However, sometimes you need a little more than this variable. NeoBook have some other variables that allows you to know certain system paths, and plugins like npInfo allows you to know some special system paths like the user documents, the common application data path, etc. You are encourage to use this kind of variables instead hard writen paths.

Sometimes you can need a system or user path (say "My Documents", for example) because "[PubDir]" can be not the best choice. For example, supose you need to extract a file from your publication and this are executed from a CDROM. In this case you cannot use "[PubDir]" in order to write anything, because the any CDROM path are writable. In cases like this you can use the NeoBook paths or as I suggest before a plugin like npInfo.

So in conclusion (and in my honest opinion/experience):

1º Avoid the use of hard writen paths like "C:\xxx\yyy" or something else. Simply never use something like that.

2º Use "[PubDir]" always than possible, deploying your publications files accordingly (relative to your executable's).

3º When you need other paths use others NeoBook path's variables or something like npInfo to obtain the right path

Hope this can help you in some manner. ;)
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Pubdir when

Postby Neosoft Support » Wed Oct 02, 2013 3:04 pm

In addition to David's advice, I would just add the following:

1. Use [PubDir] when you want to access something stored in the folder where your compiled exe is located. (Note that Microsoft does not want apps to store user data or documents under Program Files anymore.)

2. For user data, documents, databases, etc., the user's Documents folder should be used instead. For example, the following code tests for and creates (if needed) a folder under Documents for storing data:

Code: Select all
.configure folder where app's data will be stored
SetVar "[DataDir]" "[MyDocuments]AppName\"
FolderExists "[DataDir]" "[Result]"
If "[Result]" "=" "False"
  .data directory does not exist, so create it
  CreateFolder "[DataDir]"
EndIf


Replace "AppName" above with the name of your application.

You can the use [DataDir] instead of [PubDir] throughout the rest of your app.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5602
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Pubdir when

Postby BRobinsonS » Wed Oct 02, 2013 4:37 pm

The apps I have on the go (one major) keeps and looks for data in the app's folder(not under programs), but I can see a need to keep data in a sub-directory in other projects.

I generally use [Pubdir] but I thought I would like clarification.

Thanks for the input.
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest