Page 1 of 1

Fichier externe (ExternalFiles)

Posted: May 19th, 2021, 7:36 am
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.

Re: Fichier externe (ExternalFiles)

Posted: May 19th, 2021, 9:30 am
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");

Re: Fichier externe (ExternalFiles)

Posted: May 20th, 2021, 6:41 am
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.

Re: Fichier externe (ExternalFiles)

Posted: May 20th, 2021, 9:01 am
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.

Re: Fichier externe (ExternalFiles)

Posted: May 20th, 2021, 12:38 pm
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.

Re: Fichier externe (ExternalFiles)

Posted: May 20th, 2021, 1:29 pm
by Gregory Martin
How are you calculating sdata? Can you share the logic that you're using for that variable.

Re: Fichier externe (ExternalFiles)

Posted: May 21st, 2021, 5:57 am
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;

Re: Fichier externe (ExternalFiles)

Posted: May 21st, 2021, 8:45 am
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 2732 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.)

Re: Fichier externe (ExternalFiles)

Posted: May 22nd, 2021, 11:06 am
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.

Re: Fichier externe (ExternalFiles)

Posted: May 22nd, 2021, 1:37 pm
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.