Page 1 of 3

Variables and Definition Errors

Posted: Sat Mar 31, 2018 6:51 am
by asharpham
Hi all. I wasn't sure how to word a search enquiry for this one so I thought I'd post something here in the hope I can be put on the right track.

I have created an input screen using LABELs and TEXTBOXes. A number of variables have been applied to the expected entries. I want to save the results of the input to a database and then reload the empty TEXTBOXes ready for the next entry.

Initially I'd be happy if someone could guide me towards how to reuse the TEXTBOXes without closing the entry screen and reloading it. If there is a SAMPLE someone knows of I'd be happy to work through it.

To link this enquiry with the subject, I've been getting errors relating to the definitions of LABELs, BUTTONs & Variables that have already been defined. I've added a "RELEASE ALL" command but the program won't run yet because of other errors I'm working through.

I've been hesitant to upload the source because it is a fair size but will zip it and upload it if you need me to.

Regards,
Alan

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 7:21 am
by Rathinagiri
Hi Alan,

Can you make a small sample with the errors you are getting?

You can also share the error logs.

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 7:50 am
by esgici
asharpham wrote: Sat Mar 31, 2018 6:51 am ... I've been getting errors relating to the definitions of LABELs, BUTTONs & Variables that have already been defined.
...
Hi Alan

Control names are public variable throughout project and they should be unique;

so you need give name to they like this way:

@ ..., ... BUTTON MyButton_1 ...
@ ..., ... BUTTON MyButton_2 ...

instead of :

@ ..., ... BUTTON MyButton ...
@ ..., ... BUTTON MyButton ...

This may be your problem.

Happy HMG'ing :D

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 8:41 am
by asharpham
I would, Rathinagiri, but I can't see how to upload a file. And esgici, my problem is I need to reuse the buttons and labels on the screen but because they have already been defined, I'm not allowed to. It's more of a screen layout issue so I don't mind releasing the values and reapplying them, as long as the screen looks the same and the same variables can accept new values. By the way, a little off topic (very off topic acutally), I loved some of the Turkish TV programs available on Netflix in Australia, with English subtitles of course!

Alan

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 9:11 am
by dragancesu
Look atachment program in topic Indexing DBF
It's all what you need

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 9:32 am
by asharpham
Dragan, I can see that you uploaded a zip file but I can't see how you did it. I can't find anything to click on to allow a file upload.

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 9:33 am
by esgici
asharpham wrote: Sat Mar 31, 2018 8:41 am ... I need to reuse the buttons and labels on the screen but because they have already been defined, I'm not allowed to.
...
Sadly we can't change rules posed by compiler and libraries :(
I loved some of the Turkish TV programs available on Netflix in Australia, with English subtitles of course!
I'm glad that 8-) good watch:)

Viva HMG :D

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 10:15 am
by ROBROS
Hi,

Serge Girard provided the following code for me, it should solve your problem:

Code: Select all

function weiter

SetProperty('Del_1', 'Grid_1','Visible', .F.)
go Del_1.Grid_1.RecNo
cPERSNR := bbpers->persnr
cNAME := bbpers->name
cVname:= bbpers->vname
SetProperty('Del_1', 'Grid_1','Visible', .T.)
Del_1.Grid_1.SetFocus

   IF IsControlDefined ('X1' , 'Del_1' )  
      DoMethod ('Del_1' , 'X1' , 'Release' )
   ENDIF

   IF IsControlDefined ('X2' , 'Del_1' )  
      DoMethod ('Del_1' , 'X2' , 'Release' )   
   ENDIF

   IF IsControlDefined ('X4' , 'Del_1' )  
      DoMethod ('Del_1' , 'X4' , 'Release' )   
   ENDIF
   
   aKZ:={'N','J'}

DEFINE TEXTBOX    X1
   PARENT         Del_1
   ROW            850
   COL            10
   WIDTH          200 
   HEIGHT         25
   VALUE          cPERSNR+' '+alltrim(cNAME)+' '+alltrim(cVname)
   FONTCOLOR      BLACK   
   TOOLTIP        '  '
   TABSTOP        .T. 
   READONLY       .T.
END TEXTBOX

DEFINE COMBOBOX   X2   
   PARENT         Del_1
   ROW            850
   COL            340
   WIDTH          60 
   ITEMS          aKZ
   VALUE          1
   on enter weiter()
END COMBOBOX 
If the control is already defined, you simply release it and now you can define it again.
Regards Robert

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 11:56 am
by edk
asharpham wrote: Sat Mar 31, 2018 9:32 am Dragan, I can see that you uploaded a zip file but I can't see how you did it. I can't find anything to click on to allow a file upload.
1.png
1.png (5.32 KiB) Viewed 4007 times
2.png
2.png (45.38 KiB) Viewed 4007 times
3.png
3.png (45.66 KiB) Viewed 4007 times

Re: Variables and Definition Errors

Posted: Sat Mar 31, 2018 12:57 pm
by asharpham
Thanks again people. I certainly feel very slow tonight. I haven't been using the full editor today so that's how I missed it.
Music_Lib.7z
(2.7 KiB) Downloaded 243 times
This program is unfinished so not all of the menu buttons work. It loads the main menu and loads "Add New Music" but none of the other menu items work, as well as the 3 buttons at the bottom. Some of the labels aren't displaying properly either but I know I can fix that as I work on it.

I want to create code that will respond if the first box is left empty. I'm not sure how to code it so that each time there is a response to a textbox, the value of the variable is assessed and an action taken before moving on to the next textbox.

I don't need anyone to work on the rest of it as I want the exercise of doing it myself so I can learn. But if I can get some pointers on this "Add" menu item, that should help me.

Thanks again everyone.

Alan