Page 1 of 1

Help please i'm stuck

Posted: Wed Apr 19, 2017 1:43 pm
by Jose Marte
Greetings, for all, if someone could help me with this that I am going to raise, I have a variable type array that filled with several elements after reading from a file, it fills everything well, but does not present values ​​or data once Filled in instructions are as follow.

PRIVATE xUnidad := Space(9)
PRIVATE aArregloUnidad := {" "," "," "," "}

@ 12,32 DCCOMBOBOX xUnidad LIST aArregloUnidad TYPE XBPCOMBO_DROPDOWNLIST SIZE 12,08 FONT '9.Courier' ;
LostFocus {|| DC_GetRefresh(GetList,NIL,DCGETREFRESH_ID_EXCLUDE,NIL) } ;
Valid {|c| ValidarCampo(11,GetList) } When {|| cProvision == "S" }


DBSelectArea("INVFILEH")
Set Order To 1
IF DBSeek(cCodArt)
aArregloUnidad := {InvFileh->RepUn1,IIF(!Empty(InvFileh->RepUni),;
InvFileh->RepUni,Space(9)),IIF(!Empty(InvFileh->RepUns),;
InvFileh->RepUns,Space(9)),IIF(!Empty(InvFileh->RepUnx),InvFileh->RepUnx,Space(9))}
xUnidad := aArregloUnidad[1]


In the instructions I am only showing you those involved in the process that I have explained, please if someone can tell me that I am missing or that I am doing wrong. thanks in advance.

Re: Help please i'm stuck

Posted: Wed Apr 19, 2017 2:48 pm
by rdonnay
You are creating a new array pointer, whereas the DCOMBOBOX is bound to the original array pointer.

Array variables are pointers to a location in memory where the array contents can be found.

Even if you give the array variable the same name, it creates a new pointer.

You need to work with the original array pointer.

You can do this as follows:

Code: Select all

DBSelectArea("INVFILEH")
Set Order To 1
IF DBSeek(cCodArt)

  aTemp := {InvFileh->RepUn1,IIF(!Empty(InvFileh->RepUni),;
  InvFileh->RepUni,Space(9)),IIF(!Empty(InvFileh->RepUns),;
  InvFileh->RepUns,Space(9)),IIF(!Empty(InvFileh->RepUnx),InvFileh->RepUnx,Space(9))}

  ASize( aArregloUnidad, 0 )

  FOR i := 1 TO Len(aTemp)
    AAdd( aArregloUnidad, aTemp[i] )
  NEXT

ENDIF

Re: Help please i'm stuck

Posted: Wed Apr 19, 2017 3:14 pm
by Jose Marte
rdonnay wrote:You are creating a new array pointer, whereas the DCOMBOBOX is bound to the original array pointer.

Array variables are pointers to a location in memory where the array contents can be found.

Even if you give the array variable the same name, it creates a new pointer.

You need to work with the original array pointer.

You can do this as follows:

Code: Select all

DBSelectArea("INVFILEH")
Set Order To 1
IF DBSeek(cCodArt)

  aTemp := {InvFileh->RepUn1,IIF(!Empty(InvFileh->RepUni),;
  InvFileh->RepUni,Space(9)),IIF(!Empty(InvFileh->RepUns),;
  InvFileh->RepUns,Space(9)),IIF(!Empty(InvFileh->RepUnx),InvFileh->RepUnx,Space(9))}

  ASize( aArregloUnidad, 0 )

  FOR i := 1 TO Len(aTemp)
    AAdd( aArregloUnidad, aTemp[i] )
  NEXT

ENDIF
Hi, Mr., thanks, but I still have the same difficulty when I get to the unit field that is reading the DCCOMBOX, it appears empty, the arrangement to FixUnit is already filled with the different values, but the field of reading to choose which appears in White.

@ 12,32 DCCOMBOBOX xUnidad LIST aArregloUnidad TYPE XBPCOMBO_DROPDOWNLIST SIZE 12,08 FONT '9.Courier' ;
LostFocus {||DC_GetRefresh(GetList)} Valid {|c| ValidarCampo(11,GetList) } When {|| cProvision == "S" }

Re: Help please i'm stuck

Posted: Wed Apr 19, 2017 3:40 pm
by Jose Marte
rdonnay wrote:You are creating a new array pointer, whereas the DCOMBOBOX is bound to the original array pointer.

Array variables are pointers to a location in memory where the array contents can be found.

Even if you give the array variable the same name, it creates a new pointer.

You need to work with the original array pointer.

You can do this as follows:

Code: Select all

DBSelectArea("INVFILEH")
Set Order To 1
IF DBSeek(cCodArt)

  aTemp := {InvFileh->RepUn1,IIF(!Empty(InvFileh->RepUni),;
  InvFileh->RepUni,Space(9)),IIF(!Empty(InvFileh->RepUns),;
  InvFileh->RepUns,Space(9)),IIF(!Empty(InvFileh->RepUnx),InvFileh->RepUnx,Space(9))}

  ASize( aArregloUnidad, 0 )

  FOR i := 1 TO Len(aTemp)
    AAdd( aArregloUnidad, aTemp[i] )
  NEXT

ENDIF
Hi, Mr., thanks, but I still have the same difficulty when I get to the unit field that is reading the DCCOMBOX, it appears empty, the aArregloUnidad is already filled with the different values, but the field of reading to choose which appears in White.

@ 12,32 DCCOMBOBOX xUnidad LIST aArregloUnidad TYPE XBPCOMBO_DROPDOWNLIST SIZE 12,08 FONT '9.Courier' ;
LostFocus {||DC_GetRefresh(GetList)} Valid {|c| ValidarCampo(11,GetList) } When {|| cProvision == "S" }

Re: Help please i'm stuck

Posted: Wed Apr 19, 2017 3:40 pm
by rdonnay
You need a pointer to the combobox object:

@ 12,32 DCCOMBOBOX xUnidad LIST aArregloUnidad TYPE XBPCOMBO_DROPDOWNLIST SIZE 12,08 FONT '9.Courier' ;
LostFocus {|| DC_GetRefresh(GetList,NIL,DCGETREFRESH_ID_EXCLUDE,NIL) } ;
Valid {|c| ValidarCampo(11,GetList) } When {|| cProvision == "S" } ;
OBJECT oComboBox


To refresh the new value of xUnidad: DC_GetRefresh(oComboBox)

Here is another way to update the array: DC_Var2ListBox(oComboBox, aArregioUnidad)

This is simpler than the previous method I showed you.

Re: Help please i'm stuck

Posted: Wed Apr 19, 2017 4:05 pm
by Jose Marte
rdonnay wrote:You need a pointer to the combobox object:

@ 12,32 DCCOMBOBOX xUnidad LIST aArregloUnidad TYPE XBPCOMBO_DROPDOWNLIST SIZE 12,08 FONT '9.Courier' ;
LostFocus {|| DC_GetRefresh(GetList,NIL,DCGETREFRESH_ID_EXCLUDE,NIL) } ;
Valid {|c| ValidarCampo(11,GetList) } When {|| cProvision == "S" } ;
OBJECT oComboBox


To refresh the new value of xUnidad: DC_GetRefresh(oComboBox)

Here is another way to update the array: DC_Var2ListBox(oComboBox, aArregioUnidad)

This is simpler than the previous method I showed you.

Excellent, mr. Thank you, thank you.