Menu

#109 Problems with checkbox

v1.0_(example)
closed
nobody
checkbox (1)
1
2022-09-26
2022-06-28
No

Hi,
in a tool I'm building, I have a problem with checkbox.
In a for next boucle, I create checkbox using a counter named rg
for each checkbox, I give an ID it's value is rg+1000
For each checkbox, I use ON CLICK
It's in this part I have a problem
My goal is to modify a value in an array, and to modify a global counter.
The problem is, when clicking to make it, as I haven't success to retreve the good value to process array and counter.
I join the compressed source folder, and the compressed data folder. data folder has to be uncompressed in $HOME, and source folder where you want ($HOME/Desktop for example)
You have then just to modify this line in tuxmore.ini (in data path):
progpath=/opt/TuxMore
to adapt it to yor config.

Thanks for your help
A+

2 Attachments

Discussion

1 2 > >> (Page 1 of 2)
  • Aupeix Alain

    Aupeix Alain - 2022-06-29

    Hi,
    instead of creating checkbox using the step of the for next, like this

     @ 15,nlig+(28*nnum) CHECKBOX tabAccess[rg,1] SIZE 150, 22 ;
       COLOR hwg_ColorC2N("0000FF") TOOLTIP tabAccess[rg,2] ;
       ID &("lAccess"+ltrim(str(rg))) INIT .f. ;
       ON CLICK {|| rg:=&("lAccess"+ltrim(str(rg)))-1000,qout(rg)}
    //,iif(tabAccess[rg,8],nbInstall--,nbInstall++),tabAccess[rg,8]:=!tabAccess[rg,8]}
    

    where I had a problem with the value of rg, I create now, always in a for next, but no more using the step for the checkbox, like this :

    for nnum=0 to NbAccess-1
     do case
        case nnum == 0 .and. nbAccess > 0
          @ 15,nlig+(28*nnum) CHECKBOX oAccess1 CAPTION tabAccess[1,1] ;
                       SIZE 150, 22 COLOR hwg_ColorC2N("0000FF");
                       TOOLTIP tabAccess[1,2] ID iAccess1 INIT .f. ;
                       ON INIT {||Record("Access",iAccess1-1000,.t.)} ;
                       ON CLICK {||Record("Access",iAccess1-1000,.f.)}
       case nnum == 1 .and. nbAccess > 1
            @ 15,nlig+(28*nnum) CHECKBOX oAccess2 CAPTION tabAccess[2,1];   
                        SIZE 150, 22 COLOR hwg_ColorC2N("0000FF");
                        TOOLTIP tabAccess[2,2] ID iAccess1 INIT .f.
                         ON INIT {||Record("Access",iAccess2-1000,.t.)} ;
                         ON CLICK {||Record("Access",iAccess2-1000,.f.)}
     ....
    

    This solves my problem, but it needs a lot of lines more ...
    If somebody has a solution ...

    I have now another problem :
    I have a variable with an original value of O which is displayed in a tab, and which is modified by the number of checkbox checked in other tabs.

    I'm don't know how to update it.
    Here is what I done :

    hdecal=150+iif(len(ltrim(str(nbInstall)))==1,7,0)
    vdecal=249
    
    @ 10, 50 TAB oTab ITEMS {} SIZE 650, 335 ;
         ON GETFOCUS {||ajour()} ;
         ON CHANGE {||ajour()} ;
         ON CLICK {||ajour()}
    
    nlig=10
    ncol=25
    BEGIN PAGE "Stats" of oTab
       nnum=0
       @ 15,nlig+(23*nnum)+4 SAY "A installer :" SIZE 150, 22 ;
               COLOR hwg_ColorC2N("0000FF");
               TOOLTIP "Nombre de programmmes à installer"
       @ 150+iif(len(ltrim(str(nbInstall)))==1,7,0),nlig+(23*nnum)+4 ;
               SAY oSay CAPTION ltrim(str(nbInstall)) ;
               SIZE 70,22 STYLE WS_DLGFRAME  
    ....
    // ====================================================================
    function ajour()
    // =====================================================================
    
    @ hdecal,vdecal SAY oSay OF oMainWindow SIZE 70,22 STYLE WS_DLGFRAME
    
    return nil
    // =====================================================================
    

    How to refresh the display in the tab ?

    Thanks
    A+

     

    Last edit: Aupeix Alain 2022-06-29
  • Wilfried Brunken

    Hello Alain,
    sorry, i am very busy with preparation of vacation.
    I'll be absent at middle of next week and will be back last week of July.

    Please do me a favor:
    Can you send me a "makefile" (*.hbp) so i can compile your application to track the bug ?
    I hope that i can help until beginning of my vacation.

    With regards,

    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-06-30

    Hi,
    Thanks for your answer ...
    Here is the hbp file.
    You have just to update the hbc folders

    I join the last version

    A+

     

    Last edit: Aupeix Alain 2022-06-30
  • Wilfried Brunken

    Hello Alain,
    can not find the file "hbversion.ch"
    on my system.

    cltest@afu-DA320-Series:~/TuxMore/source$ hbmk2 TuxMore.hbp
    hbmk2: Processing environment options: -comp=gcc
    Harbour 3.2.0dev (r2104281802)
    Copyright (c) 1999-2021, https://harbour.github.io/
    TuxMore.prg(12) Error F0029 Can't open #include file 'hbversion.ch'
    hbmk2[TuxMore]: Error: Running Harbour compiler (built-in). 1
    ('/home/cltest/Harbour/core-master/bin/linux/gcc/harbour') -n2 TuxMore.prg colors.prg initools.prg execute.prg keyboard.prg folders.prg docs.prg printer.prg SiteWeb.prg -w3 -q -m -n -es2 -DHBMK_HAS_HWGUI=1 -DHBMK_HAS_HBCT=1 -o/tmp/hbmk_r7csor.dir/ -i/home/cltest/Harbour/core-master/include -i/home/cltest/svnwork/hwgui-code/hwgui/include -i/home/cltest/Harbour/core-master/contrib/hbct

    I used a code snapshot of Harbour from 19th may 2022.
    I attached my hbp file.

    With regards,

    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-07-01

    hi,

    Sorry, I miss it.

    To bypass this, just add this before memvar:

    #ifndef Harbour_Version
     #define Harbour_Version           ""
    #endif
    
    #ifndef Harbour_bits
     #define Harbour_bits              ""
    #endif
    
    #ifndef HwGui_Rev   
       #define HwGui_Rev               ""
    #endif
    

    This #define are to complete harbour and hwgui version (these give revisions).
    They are made during my script to update source, and build harbour and hwgui.

    I thought, and now too, that the precise version used during applications builds is very important to know if a new bug can be introduced by a new version of hb or hw.

    /*
     * Harbour Project source code:
     * Header file to help catch reserved keywords
     *
     * Copyright 2015-2019 Alain Aupeix
     */
    
    #ifndef Harbour_Version
    
       #define Harbour_Version               "Harbour 3.2.0dev (r2021-04-28 18:02)"
    #endif /* Harbour_Version */
    
    /*
    * Harbour Project source code:
    * Header file to help catch reserved keywords
    *
    * Copyright 2015-2018 Alain Aupeix
    */
    
    #ifndef HwGui_Rev   
       #define HwGui_Rev               "3067"
    #endif /* HwGui_Rev */
    
     
  • Aupeix Alain

    Aupeix Alain - 2022-07-01

    They are built by jharbour using hbv1, hbv1, hbit1, hbit2

    A+

     
  • Aupeix Alain

    Aupeix Alain - 2022-07-01

    The last version

     
  • Aupeix Alain

    Aupeix Alain - 2022-07-02

    Another new version:
    - some typos corrected
    - Function Installer() is quite finished now

    To do :
    - add/Remove a package
    - logfile
    + some other things.

    A+

     
  • Wilfried Brunken

    Hello Alain,

    Following trouble compiling your new revision:

    Added in TuxMore.hbp to find hcedit.ch:
    -I/home/cltest/svnwork/hwgui-code/hwgui/utils/editor

    Missing file on my sytem:
    letters.ch

    But the old version is running.

    At the first start i got the message:
    sh: 1: splash: not found

    So i installed "splash" by
    sudo apt-get install splash.

    After start, splash requests a response, see snapshots.
    What should i do ?

    The installation of TuxMore seems to be confusing.
    I recommend, to extract a sample of your application only
    demonstrating your problem.
    I think, this is the easiest way to fix the bug.

    An advice:
    METHOD Value( lValue ) CLASS HCheckButton
    should set the value of a check button.

    With regards,

    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-07-04

    Hi, no the installation is not confusing, but I miss some details ...

    • It's not this version of splash, but one I made.
    • I forgot, as you said to add hcedit.ch, as on my system, I put all the hwgui ch files in the same folder (/usr/include/hwgui), including the one of utils and contrib.
    • letter.ch is not needed, and can be removed. I have cleaned this part, and now:
    #include "hwgui.ch"
    #include "hcedit.ch"
    #include "hbversion.ch"
    #include "hbver.ch"
    #include "hwgui_rev.ch"
    
    • Concerning data(), I have seen it, and I use it in 0.12 and later. But the problem I had in 0.10 was with ON CLICK where I didn't know how to no more use rg, as this variable keep the last affected value .

    A+

     

    Last edit: Aupeix Alain 2022-07-16
  • Wilfried Brunken

    Hello Alain,
    i hope, the commit r3094 is some part of your fix.

    I'll continue the work today evening.

    With regards,

    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Wilfried Brunken

    Hello Alain,

    I have seen a problem, that you can not modify the values
    of the checkboxes in the tab's (Button "Tout" = "All" and "Erracer" = "Delete").

    I hope, the new sample helps you to fix this problem
    (commit r3096).

    Now i'll be absent until last week of july.
    Please be patient, then i will continue my work with HWGUI and CLLOG.

    With regards,

    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-07-06

    Hi,
    As I said, I found value() function, and I use it now.
    Your example is nice , but you can add a function invert(). It's nice when there are a lot of checkboxes, and you just want to check all except some. You have just to check the ones you don't want to check, and invert().

    But the problem I had was when initializing checkboxes in a for next boucle, and using the counter in ON CLICK because the counter was modified, and no more in accordance with the checkbox.

    For now, I don't initialize it using the counter, but it needs more and more code lines ... :(
    I'm not sure there is a solution ...

    Thanks
    A+

     

    Last edit: Aupeix Alain 2022-07-16
  • Aupeix Alain

    Aupeix Alain - 2022-07-18

    Some modifications:
    - structure of tuxmore.dbf to allow comments, and improvement of the data
    - added comments button
    - install is now depending of a checbox which allow to simulate or launch the installation.
    - some typos removed.

    To do :
    - add a program
    - remove a program
    - help
    - localization ??

    A+

     
  • Wilfried Brunken

    Hello Alain,
    concerning your request i added the Invert() method
    to the HCheckButton class with commit r3098.

    I hope, this helps you.

    I think, you should create a new project "TuxMore"
    on sourceforge.net.

    On next monday, i'll continue my work and
    check the last revision of TuxMore.

    Have a nice weekend.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-07-23

    Hi,
    Nice, it remove the need of a test:

           &(objet):invert()
    //       if &(objet):value
    //          &(objet):value=.f.
    //       else
    //          &(objet):value=.t.
    //       endif
    

    But my fisrt problem was to create checkbox in a for ... next.
    The creation works nicely, but the ON CLICK doesn't work, as the numeric variable used as counter of for next changes, and the macro used to select the array is wrong.

    I found a way which works, but uses a lot of code.
    I'm aware that there is probably no other solution that using more code ...

    Thanks
    A+

     
  • Aupeix Alain

    Aupeix Alain - 2022-07-24

    Hi,
    When testing invert(), I found a typo in tuxmore.dbf (missing filename).

    wget -O sagasu2.0.12-5amd64.deb https://www.dropbox.com/s/1b25tzch1h1kiju/sagasu_2.0.12-5_amd64.deb?dl=1 ;dpkg -i sagasu_2.0.12-5_amd64.deb

    Also, I found a bug in execute.prg, when there is one of these characters ( \ < >) in the field 'command'. These characters have to be escaped for a simulation.

    To do :
    - update of tuxmore.dbf
    - add a program
    - remove a program
    - modify a program

    A+

     

    Last edit: Aupeix Alain 2022-07-24
  • Aupeix Alain

    Aupeix Alain - 2022-08-17

    Hi Wilfried,

    Here is a test for my problems with checkbox creation in a for next.

    I think that I have found the solution. The way seems to create variables with are depending of the counter, and in checkbox, use macros.

    I notice that if I declare lcheck, I have an error, else, just :

    Compiling 'Test_for_check.prg'...
    Test_for_check.prg(128) Warning W0001  Ambiguous reference 'LCHECK'
    Test_for_check.prg(129) Warning W0001  Ambiguous reference 'LCHECK'
    

    What is your advice ?

    Thanks
    A+

     

    Last edit: Aupeix Alain 2022-08-17
  • Wilfried Brunken

    Hello Alain,

    remove the "&" from line 129:
    &lcheck=tabAccess[nnum+1,3]
    that seems to be the error.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-09-22

    Hi Wilfried,

    Here is the concerned part of code:

    // local lcheck
    ...
    128 lcheck="lAccess"+ltrim(str(nnum+1))
    129 &lcheck=tabAccess[nnum+1,3]
    130 @ 10,nlig+(28*nnum) CHECKBOX &cObjet CAPTION tabAccess[rg,1] ;
              SIZE 150, 22 COLOR hwg_ColorC2N("0000FF");
             INIT .f. TOOLTIP cObjComment ID &ID_ACCESS ;
             ON CLICK {|| iif(&lCheck,nbInstall--,nbInstall++),&lcheck:=!&lcheck}
    

    If I comment the local declaration, it works, just these warnings :

    Test_for_check.prg(128) Warning W0001  Ambiguous reference 'LCHECK'
    Test_for_check.prg(129) Warning W0001  Ambiguous reference 'LCHECK'
    

    If I uncomment the local declaration, it fails when compiling :

    Test_for_check.prg(132) Error E0047  Code block contains both macro and declared symbol references 'LCHECK'
    Test_for_check.prg(132) Error E0047  Code block contains both macro and declared symbol references 'LCHECK'
    Test_for_check.prg(132) Error E0047  Code block contains both macro and declared symbol references 'LCHECK'
    Test_for_check.prg(132) Error E0042  Macro of declared symbol '{|| iif(&lCheck,nbInstall--,nbInstall++),&lcheck:= !&lcheck}'
    4 errors
    
    No code generated.
    

    If I remove the & with local uncommented, it fails when compiling:

    Test_for_check.prg(132) Error E0047  Code block contains both macro and declared symbol references 'LCHECK'
    Test_for_check.prg(132) Error E0047  Code block contains both macro and declared symbol references 'LCHECK'
    Test_for_check.prg(132) Error E0047  Code block contains both macro and declared symbol references 'LCHECK'
    Test_for_check.prg(132) Error E0042  Macro of declared symbol '{|| iif(&lCheck,nbInstall--,nbInstall++),&lcheck:= !&lcheck}'
    4 errors
    
    No code generated.
    

    If I remove the & (on line 132) with local uncommented, no error, no warning.
    but in this case, all the checkbox will share the same value ...

    I have modified the prg (added some qout(), to comment the problem, so it must be run from a terminal.

    A+

     

    Last edit: Aupeix Alain 2022-09-22
  • Aupeix Alain

    Aupeix Alain - 2022-09-22
    Post awaiting moderation.
  • Wilfried Brunken

    Hello Alain,

    i tested the Program "Test_for_check.prg" from
    the last posted archive " test-for-check(2).tar.bz2" and it is running
    with no trouble.

    The only modification was:
    qout("here is now the value of lchyeck :")
    Add a ")" at the end of the line 129.

    I added the include directory from hwmake and
    used the posted hbp file for compiling.

    The output was:

    ltest@afu-DA320-Series:~/T2/test-for-check$ hbmk2 Test_for_check.hbp
    hbmk2: Processing environment options: -comp=gcc
    Harbour 3.2.0dev (r2104281802)
    Copyright (c) 1999-2021, https://harbour.github.io/
    cltest@afu-DA320-Series:~/T2/test-for-check$ ./Test_for_check

      1001
    

    But the qout() outputs are not visible.
    What must i now do to provcate the bug ?

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-09-23

    Hi Wilfried,

    I made a new version, but didn't test it before sending it. And there was a bug, and an incomplete demonstration of the problem.
    I send again a new debugged and improved version, but without removing the bad version. I thought the change was done, but it was not.
    Now, I send the good test with explanations. You must run it from a terminal
    ./Tast_tab
    ok ?

    Thanks
    A+

     

    Last edit: Aupeix Alain 2022-09-23
  • Wilfried Brunken

    Hello Alain:
    I modified x,y CHECKBOX .. to x,y GET CHECKBOX VAR lcheck ...
    also ini lcheck with .F.
    I hope, that is what you decide.

    Now the value of lcheck toggled between .F. and .T..
    Output in Terminal:
    so the same value is shared by all the checkbox, which is bad

    .T.
    .T.
    .F.
    .F.
    .T.
    .T.
    .F.
    .F.
    .T.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-09-23

    Hi Wilfried,

    Yes, now it works without problem.

    I have just clean the prg, and add some qout() to demonstrate that it works correctly ...
    I just had to invert in ON CLICK nbInstall-- and nbinstall++, as when ON CLICK is called the value of lcheck has already changed.

    I think you can close ... I just have to modify TuxMore to apply these modifications.

    Thanks
    A+

     

    Last edit: Aupeix Alain 2022-09-23
1 2 > >> (Page 1 of 2)

Log in to post a comment.