Buen Día:
Disculpa que no lo escriba en ingles (ya que no se), pero espero se entienda con el traductor de google.
1. Según veo, tienes un error de sintaxis:
store lcNewVal to ( pcVarName ) // Forma incorrecta
store lcNewVal to pcVarName // Forma correcta
2. No tengo mucha experiencia en programación, pero tengo un libro de clipper que menciona el comando store como obsoleto, se recomienda la asignación en linea, mucho mas practico:
lcNewVal := pcVarName
Gracias por su amable respuesta. La sintaxis que sugiere es correcta si quiero cambiar el valor de la variable lcNewVal.
Su resultado es idéntico a: lcNewVal: = pcVarName.
Lo que realmente necesito cambiar es el valor de la variable llamada en pcVarName. No quiero simplemente cambiar el valor de pcVarName en sí. En cambio, es la variable nombrada en su contenido (pcVarName: = "oUserAns: OStreet1"). Es decir, el punto es cambiar (indirectamente) el valor de oUserAns: OStreet1.
En última instancia, quiero que el valor de oUserAns: OStreet1 sea "123 Different Street" (es decir, lcNewVal).
Simplemente no entiendo cómo Clipper, Harbor y HMG codifican esto. En FoxPro y Visual FoxPro, esto se llama "asignación indirecta", según recuerdo.
Estoy seguro de que hay alguna sintaxis para hacer esto en HMG, pero aún no la he encontrado. ¿Alguna otra idea?
De nuevo, gracias por tu ayuda.
Saludos cordiales,
Red2
/////////////
Thank you for your kind response. The syntax you suggest is correct if I want to change the valuable of variable lcNewVal.
Its result is identical to: lcNewVal := pcVarName.
What I need to actually change is the value of the variable named in pcVarName. I do not want to simply change the value of pcVarName itself. Instead, it is the variable named in it's contents (pcVarName := "oUserAns:OStreet1"). That is, the point is to change (indirectly) the value of oUserAns:OStreet1.
Ultimately I want the value of oUserAns:OStreet1 to be "123 Different Street" (i.e. lcNewVal).
I simply don't understand how Clipper, Harbour, and HMG code this. In FoxPro and Visual FoxPro this is called "indirect assignment" as I recall.
I am sure that there is some syntax to do this in HMG but I have not found it yet. Any other ideas?
Vielen Dank, ich schätze Ihre Hilfe sehr. Ich glaube, dass Ihr Vorschlag den Wert von lcNewVal ändert.
Eigentlich muss ich (indirekt) den Wert von oUserAns: OStreet1 in den Wert von lcNewVal ändern. Wichtig: Ich möchte nicht, dass sich die Werte von lcNewVal oder pcVarName ändern.
Um dies (indirekt) zu tun, muss die Variable, die durch den Zeichenfolgenwert von pcVarName ("oUserAns: OStreet1") angegeben ist, aktualisiert werden. Mache ich hier sinn?
Dies ist in VFP einfach zu bewerkstelligen. Wie geht das in HMG / Harbour?
Nochmals vielen Dank für Ihre großzügige Anleitung.
Red2
* * * * * * * * * * *
Hello AUGE_OHR,
Thank you, I very much appreciate your help. I that believe that your suggestion changes the value of lcNewVal.
Actually, I need to (indirectly) change the value of oUserAns:OStreet1 to the value of lcNewVal. Important: I do NOT want the values of either lcNewVal or pcVarName to change.
To do this (indirectly) I need the variable indicated by the string value of pcVarName ("oUserAns:OStreet1") to be updated. Do I make sense here?
This is easy to do in VFP. So, how is this done in HMG/Harbour?
Claro, esa es una gran pregunta. Haré todo lo posible para decir por qué. Durante el OnInit de un formulario, el contenido de un archivo de texto se lee en una variable. Esa variable se analiza y se asignan ciertos valores a un objeto de formulario.
Los valores de propiedad de este objeto, entonces, se asignan a los valores de TextBox del formulario.
Cuando se guarda el formulario, recorro todos los cuadros de texto. Si un TextBox ha cambiado, se pasan dos parámetros a una función:
1) El nombre de la propiedad del objeto relevante como una cadena, es decir, "oUserAns: OStreet1" (no la propiedad del objeto en sí).
2) El valor actual de TextBox
La función debe:
1) Actualice el objeto de formulario que originalmente asignó el valor de TextBox
2) La variable de memoria del archivo de texto (completo) debe analizarse y actualizarse con precisión.
El punto es que puedo minimizar la cantidad de código y hacer de manera inteligente todas las actualizaciones necesarias. Sin duda, otro programador presentaría una solución superior.
Espero que esta simple explicación sea útil.
Saludos cordiales,
* * * * * * * * *
Sure, that's a great question. I'll do my best to state why. During a form's OnInit a text file's contents is read into a variable. That variable is parsed and certain values are assigned to a form object.
This object's property values are, then, assigned to the form's TextBox values.
When the form is saved I iterate through all TextBoxes. If a TextBox has changed then two parameters are passed to a function:
1) The name of the relevant object property as a string, i.e. "oUserAns:OStreet1" (not the object property itself).
2) The TextBox's current value
The function must:
1) Update the form object that originally assigned the TextBox's value
2) The memory variable of (entire) text file must be parsed and accurately updated.
The point is that I can minimize the amount of code and intelligently make all necessary updates. Another programmer would undoubtedly come up with a superior solution.
Excelente, muchas gracias por tu respuesta.
De hecho creo que vi algo parecido por aquí, alguien de este foro comento que trataba de normalizar los nombres de los campos de una base de datos, con los nombres de los texbox, y mediante un ciclo recorrer todos los campos del formulario e ir actualizando la base da datos.
La propuesta que tu presentas por lo que entiendo va encaminado a la misma solución y objetivo de ahorro de código, solo que a mi en lo particular todavía me cuesta un poco aplicar.