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
inserting picture into CSPro
Re: inserting picture into CSPro
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.
Re: inserting picture into CSPro
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!
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!
Re: inserting picture into CSPro
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.
Re: inserting picture into CSPro
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
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
Re: inserting picture into CSPro
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
- csentry
- MyApp
- MyApp.pen
- MyApp.pff
- photos
- antestia.jpg
Re: inserting picture into CSPro
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;
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;
Re: inserting picture into CSPro
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:
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:
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.
Code: Select all
PROC PICTURE
showAntestia();
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.