Fichier externe (ExternalFiles)

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
guyzzo
Posts: 6
Joined: May 18th, 2021, 5:18 am

Fichier externe (ExternalFiles)

Post by guyzzo »

Bonjour,

J'utilise une application de saisie avec un dictionnaire externe (version 7.5 de CSPro). Cela marche bien dans Windows, mais
sur Android, il n'arrive pas à ouvrir le fichier de données associé au dictionnaire externe. Il referencie mal le chemin d'accès
au fichier de données, il rajoute / avant CSEntry et ajoute ; dans le chiffre passé en paramétre.
Merci pour votre aide.


Hello,

I am using an input application with an external dictionary (version 7.5 of CSPro). It works fine in Windows, but
on Android, it cannot open the data file associated with the external dictionary. He badly references the access path
to the data file, it adds / before CSEntry and adds; in the figure passed in parameter.
Thanks for your help.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Fichier externe (ExternalFiles)

Post by Gregory Martin »

How are you creating the name of your file? If you are using Windows and Android, we strongly suggest using the pathname and pathconcat functions because they take into account the differences in the systems. For example, if I wanted to access a file relative to where my application is running, I might do this:
pathconcat(Application, "../Data/Household.csdb");
guyzzo
Posts: 6
Joined: May 18th, 2021, 5:18 am

Re: Fichier externe (ExternalFiles)

Post by guyzzo »

Thanks for your reply.

I create the pff dynamically by using those lines of command :

SAISIE.setproperty("[ExternalFiles]","");
SAISIE.setproperty("EXO_DICT", pathconcat(strip(sdata),strip(slash),"EXO",maketext("%v.csdb", edit("9999",OP))));
SAISIE.setproperty("ASSIGN_DICT", concat(strip(refe),strip(slash),"ASSIGN.csdb"));

Unfortunatley I have the message the file associated to EXO_DICT could not be open.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Fichier externe (ExternalFiles)

Post by Gregory Martin »

Does the directory EXO exist? If not, you might consider doing this:
string exo_directory = pathconcat(strip(sdata), "EXO");
dircreate(exo_directory);

SAISIE.setproperty(
"EXO_DICT", pathconcat(exo_directory, maketext("%04d.csdb", OP)));
Also, you don't need to add slashes to the pathconcat function; it will automatically add them.
guyzzo
Posts: 6
Joined: May 18th, 2021, 5:18 am

Re: Fichier externe (ExternalFiles)

Post by guyzzo »

Thanks a lot for you help.

I use your suggestion. But, unfortunately I have

Error(10102) Could not open the data source EXO_DICT : the data files does not exist : /storage/emulated/0/Android/data/gov.census.cspro.csentry/files/csentry//SURVEY/EXO/DATA/EXO131;1.csdb

with OP = 1311 and this instruction
SAISIE.setproperty("EXO_DICT", pathconcat(strip(sdata),concat("EXO", maketext("%04d.csdb", OP))));

I don't understand why before SURVEY he have // instead of / ?
In addition I don't know where ; is coming from ?

I am using a LENOVO tablet (TAB37 ESSENTIAL).

Thanks in advance.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Fichier externe (ExternalFiles)

Post by Gregory Martin »

How are you calculating sdata? Can you share the logic that you're using for that variable.
guyzzo
Posts: 6
Joined: May 18th, 2021, 5:18 am

Re: Fichier externe (ExternalFiles)

Post by guyzzo »

The way I create the data folder :

if getos() = 10 then
wrkprj = pathconcat("C:","SURVEY","EXO");
entry = pathconcat( strip(wrkprj), "ENTRY");
refe = pathconcat( strip(wrkprj), "REFE" );
SData = pathconcat( strip(wrkprj), "DATA" );
elseif getos() in 20 then //Android
wrkprj = pathconcat(strip(Pathname(CSEntry)),"SURVEY","EXO");
entry = pathconcat( strip(wrkprj), "ENTRY");
sdata = pathconcat( strip(wrkprj), "DATA");
endif;
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Fichier externe (ExternalFiles)

Post by Gregory Martin »

Your code seems fine. I tested it myself:
string wrkprj = pathconcat(strip(Pathname(CSEntry)), "SURVEY", "EXO");
string entry = pathconcat(strip(wrkprj), "ENTRY");
string sdata = pathconcat(strip(wrkprj), "DATA");

numeric OP = 1311;

pff SAISIE;
SAISIE.setproperty(
"EXO_DICT", pathconcat(strip(sdata), concat("EXO", maketext("%04d.csdb", OP))));

errmsg("%s", SAISIE.getproperty("EXO_DICT"));
You can see that my path is correct.
EXO.png
EXO.png (16.92 KiB) Viewed 2688 times
If you add an errmsg like I did, does it appear correctly just after you use setproperty?

(Also, assuming that wrkprj, entry, refe, and sdata are alpha variables in logic, I encourage you to switch to using string instead. Then you can simplify your code by removing all of the strip statements.)
guyzzo
Posts: 6
Joined: May 18th, 2021, 5:18 am

Re: Fichier externe (ExternalFiles)

Post by guyzzo »

Thanks for you reply.
I just do what you have wrote.
The errmsg release the good path but the error 10102 still there.
Let's me check the whole program before share it with you.
Best regards.
guyzzo
Posts: 6
Joined: May 18th, 2021, 5:18 am

Re: Fichier externe (ExternalFiles)

Post by guyzzo »

Thanks a lot Gregory Martin.

You was correct. I juste realize that I wrongly but a ; in the command when calling the
file associated to EXO_DICT. The thing work correctly know.

Thanks.
Post Reply