Page 1 of 1

Urgent Assistance Needed: Script Overflow Issue Causing Program Shutdown!

Posted: March 20th, 2024, 5:40 pm
by lalvarado
Hello friends,

I am a completely new user in the world of CSPro, and I would like to ask for your support with an issue I am facing. I am working on a data entry project in which I have a script with over 4 thousand records. However, this volume of data is causing the program to shut down completely when compiling or running it.

I have noticed that if I limit the number of characters, the program works correctly. The script consists of assigning values to different variables when entering a specific code, as shown below:

PROC IDSTUDENT
if IDSTUDENT = "G123" then
cod_centro = "040200002B20";
depto = "COPAN";
muni = "CABANAS";
n_centro = "28 DE FEBRERO";
idschool = "IH055";
n_alumno = "MARBENI XIOMARA FRANCO CASTRO";
elseif IDSTUDENT = "G124" then
cod_centro = "040200002B20";
depto = "COPAN";
muni = "CABANAS";
n_centro = "28 DE FEBRERO";
idschool = "IH055";
n_alumno = "KENIA MARIBEL LEIVA ALVARADO";
elseif IDSTUDENT = "G125" then
cod_centro = "040200002B20";
depto = "COPAN";
muni = "CABANAS";
n_centro = "28 DE FEBRERO";
idschool = "IH055";
n_alumno = "MARYURI YORLENI INTERIANO GUEVARA";
elseif IDSTUDENT = "G126" then
cod_centro = "040200002B20";
depto = "COPAN";
muni = "CABANAS";
n_centro = "28 DE FEBRERO";
idschool = "IH055";
n_alumno = "LESLY YOHELY MORALES JAVIER";

This is the structure of the script, but as I mentioned, it has over 4 thousand records, which is causing issues. Could you please help me solve this?

Thank you very much for your attention and collaboration!

Best regards,

LEONARD
PlantillaTercer Ciclo 2024.zip
this is the project I am working on.
(109.3 KiB) Downloaded 25 times

Re: Urgent Assistance Needed: Script Overflow Issue Causing Program Shutdown!

Posted: March 21st, 2024, 9:13 am
by Gregory Martin
Typically you do this with a lookup file. You create a lookup file, typically in Excel, that maps the IDSTUDENT value to the depto, muni, etc. variables. This makes it easier to maintain your mappings, will speed up your program immensely, and will avoid the problem of the script overflow.

Take a look at the workshop materials on lookup files: https://www.csprousers.org/mobile-works ... -ctrl.html

We can help you if you have further questions about this approach.

Re: Urgent Assistance Needed: Script Overflow Issue Causing Program Shutdown!

Posted: March 25th, 2024, 8:08 am
by vgonzalez
Estimado colega Alvarado,

Le escribo para recomendarle como indica Gregory, la mejor solución para la necesidad que precisas es hacer uso de un diccionario complementario que le permita a través de una lista, identificar las opciones para la división administrativa y los establecimientos educativos.

Sin embargo, te recomiendo que el orden de identificación y selección lo coloques según se dividen las áreas de la República de Honduras, que si mal no recuerdo son Departamento, luego Municipio, luego creo hay otra división, anterior, sino, la lista de los centros educativos filtrados para el municipio seleccionado.

Creo si lo compartes te podrán ayudar con una propuesta para ello aquí mismo en el Foro.

Saludos y éxitos en la evaluación del proyecto

Re: Urgent Assistance Needed: Script Overflow Issue Causing Program Shutdown!

Posted: March 25th, 2024, 11:55 am
by lalvarado
Thank you Gregory, I followed your recommendation and created a data file in Excel as a base with all the records, then I created the dcf dictionary according to the Excel file and created the .dat file, I named them as "SEARCH", the inconvenience that I have at the moment is that I cannot make the call of those files in my Data Entry application, I try to do it in the IDSTUDENT variable but I can't get it to write the data in this variable to search and fill in the other variables, they could help me with this. Thank you, I'll share the project for you to take a look at, thanks in advance.
1 diccionario.zip
Project
(152.13 KiB) Downloaded 19 times

Re: Urgent Assistance Needed: Script Overflow Issue Causing Program Shutdown!

Posted: March 26th, 2024, 11:28 am
by justinlakier
Hello,

I have attached a modified working version which I will explain. It required multiple dictionary changes. You should be using loadcase() to load the case and its values rather than find() or findcase. As demonstrated in the example on the loadcase page, the dictionary name argument should not be in quotation marks as a string. In order to load the case, I have added ESTUDIANTES_DICT as an external dictionary using File -> Add File. This caused a number of problems, since there are items in the PRUEBA dictionary that have the same name as items in the ESTUDIANTES dictionary. To fix this I prefixed the problematic items with "PRUEBA_" so that it is clear which dictionary they are being used in. Prefixing of not just the problematic items but the entire dictionary is common practice when using multiple dictionaries, to help clarity and prevent name overlaps. Going through the code and renaming/prefixing afterwards when name overlaps cause compile issues is more effort. I also had to reduce the length of PRUEBA_IDSTUDENT so that it matched the length of the IDSTUDENT variable in ESTUDIANTES_DICT. I made them both length 6 to match the data in the .dat file, however you may wish to make both IDSTUDENT dictionary items length 10 instead. They must both be the same length for loadcase() to work though. Finally, I fixed the code in PRUEBA_IDSTUDENT so that it takes the variables from loadcase(ESTUDIANTES_DICT) and sets the PRUEBA dictionary variables with the same value. This does not require getvalue() since loadcase loads the value. You can see more examples of lookup files in the examples folder or in the documentation. Please let us know if you have any additional questions.

Hope this helps,
Justin

Re: Urgent Assistance Needed: Script Overflow Issue Causing Program Shutdown!

Posted: March 30th, 2024, 5:29 pm
by lalvarado
Hi Justinlaker,

I thank you very much for having taken the time to respond to my request, thank you for all your collaboration, it was of great support to me to be able to complete the project and thus be able to start with the data entry.