inserting picture into CSPro

Discussions about CSEntry
Post Reply
sjonabro

inserting picture into CSPro

Post by sjonabro »

Hello,

I inserted a picture into the question field of the forms section in CSPro, but when I go to the tablet, I see only text come up, no image... I get something like this:
Paint.Picture01050000000000007000000000504 ... 04482
Do you know why the image is not coming up?

Thanks!
Aniseh
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: inserting picture into CSPro

Post by josh »

CSPro can't display a picture in a field. You will need to use the execsystem command in your logic to display the picture in an external application. See http://teleyah.com/cspro/DCJune2015/07- ... diaGPS.pdf for an example.
sjonabro

Re: inserting picture into CSPro

Post by sjonabro »

Thanks Josh,
I followed the code in the example and I get an error when I try to compile. Maybe it is because I don't understand the "function()" command.
This is what I wrote:

PROC ANTPHOTO
function showAntestia()
execsystem(maketext("view:%photos/antestia.jpg", pathname(Application)));
end;

And I get the following error:
Expecting ';' or operator near line 1 in ANTPHOTO procedure.

Thanks for your help!
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: inserting picture into CSPro

Post by josh »

Function definitions must be in the proc global. You cannot define a function inside the proc for a field. You should read up on functions in the online help.
sjonabro

Re: inserting picture into CSPro

Post by sjonabro »

Hi - I am still struggling with this.
I have tried a few different things and am still unable to get a good outcome. I read through the help file on functions and looked for questions in the forum.
I am still unable to display a picture in the tablet.

The closest I have come to doing that, was when the tablet gave me the option to look for the picture in the gallery or in myphotos. In both cases, even though the photo was in both locations, it gave me a message saying that the image had not been found.
Any help would be appreciated. Thanks!
Aniseh
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: inserting picture into CSPro

Post by josh »

This is most likely because you do not have the correct path to the photo. Execsystem expects the full path to the photo file. In the code that you posted your function is telling CSPro to look for the photo in the directory "photos" that is a subdirectory of the application directory. So on the tablet you need a directory structure like:


- csentry
- MyApp
- MyApp.pen
- MyApp.pff
- photos
- antestia.jpg
sjonabro

Re: inserting picture into CSPro

Post by sjonabro »

Thanks Josh,
I tried doing that as well, I first saved the picture in the photos folder in the tablet, and then specified the path: ("view:/tab/Tablet/csentry/SurveyName/photos/photo.jpg")

I think part of the problem is that I cannot figure out how to call the function that I created in proc global when the question in the survey comes up. I did not see a good example of how to call the function in any of the help files.

So right now I have:

PROC GLOBAL
function showAntestia()
execsystem("view:/tab/Tablet/csentry/SurveyName/photos/photo.jpg");
end;
.
.
.
PROC PICTURE
and here I have tried:
showAntestia();
and
execsystem("view:/tab/Tablet/csentry/SurveyName/photos/photo.jpg");
end;
and
if execsystem("view:/tab/Tablet/csentry/SurveyName/photos/photo.jpg") <>1 then
errmsg("bla bla bla");
endif;
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: inserting picture into CSPro

Post by josh »

Functions in CSPro are similar to functions in most other programming languages. You can call them from any proc by just writing the function name followed by the arguments in parenthesis. Since your function doesn't have any arguments you just use empty parenthesis:

Code: Select all

    PROC PICTURE
    showAntestia();
Note that this will call the function in the POSTPROC of the field PICTURE which is after you enter the value for the field. If you want to show it as soon as you enter the field then use the PREPROC or the ONFOCUS proc like:

Code: Select all

    PROC PICTURE
    onfocus
    showAntestia();

If you aren't comfortable with functions then don't use it. Just call execsystem() directly in your proc. The function is only useful if you want have some logic that you can call from multiple procs but if you are only using it one place it doesn't offer much advantage.

The path /tab/tablet/csentry looks strange to me. On most devices I've seen the csentry directory is in a path like /sdcard/csentry or /mnt/sdcard/csentry.Of course this varies from device to device which is why we recommend using pathname(Application).

We just released CSPro 6.2 which now supports images in value sets. This might be a simpler solution to your problem. Look under "Value set images" in the help.
sjonabro

Re: inserting picture into CSPro

Post by sjonabro »

This was so helpful. Thank you Josh.
Post Reply