evertonlb Posted December 10, 2013 Report Share Posted December 10, 2013 Boa tarde amigos estou com uma dificuldade em algo de supostamente seria simples... fiz uma função onde eu envio alguns dados ( descritos abaixo ) assim eu tenho maior autonomia sobre cores e tamanho da letra da mensagem dados enviados à função ex.: ( cVarRetorno, Lin1Msg, Lin2Msg, Lin3Msg, lin4Msg,; captionbtn1, imgbtn1, MsgBtn1,; captionbtn2, imgbtn2, MsgBtn2,; captionbtn3, imgbtn3, MsgBtn3,; captionbtn4, imgbtn4, MsgBtn4 ) Então conforme a opção escolhida na função eu devolveria um valor, assim com um IF eu executaria a rotina escolhida Porem não volta valor algum.. segue o código da função. Obs.. Já fiz algumas alterações no código, mas não tive sucesso. Function Ini_oForm_Choise(Ret_Func, x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) @ 1, 6 GROUP oGrp1 TO 99, 514 LABEL "" PIXEL; OF oForm_Choise COLOR 0, 15790320 FONT oFont1 @ 12, 10 SAY oSay1 VAR x_c_Linha1 SIZE 492, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 31, 10 SAY oSay2 VAR x_c_Linha2 SIZE 490, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 50, 10 SAY oSay3 VAR x_c_Linha3 SIZE 487, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 69, 11 SAY oSay4 VAR x_c_Linha4 SIZE 491, 16 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 if CpBt1 <> NIL @ 103, 6 BTNBMP oBtn1 Prompt CpBt1; FILE Img1 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret(Ret_Func, oForm_Choise,1) FONT oFont1 message Tool1 oBtn1:SETCOLOR( 0, 14342874 ) endif * if CpBt2 <> NIL @ 103, 106 BTNBMP oBtn2 Prompt CpBt2; FILE Img2 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret(Ret_Func, oForm_Choise,2) FONT oFont1 message Tool2 oBtn2:SETCOLOR( 0, 14342874 ) endif * if CpBt3 <> NIL @ 103, 206 BTNBMP oBtn3 Prompt CpBt3; FILE Img3 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret(Ret_Func, oForm_Choise,3) FONT oFont1 message Tool3 oBtn3:SETCOLOR( 0, 14342874 ) endif * if CpBt4 <> NIL @ 103, 306 BTNBMP oBtn4 Prompt CpBt4; FILE Img4 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret(Ret_Func, oForm_Choise,4) FONT oFont1 message Tool4 oBtn4:SETCOLOR( 0, 14342874 ) endif * @ 103, 434 BTNBMP oBtn5 Prompt "Sair"; FILE "Imagens\16\EXIT.bmp" SIZE 80, 26 PIXEL LEFT; OF oForm_Choise ACTION if( MsgInfo( "Tem certeza que deseja sair sem escolher nenhuma das opções?", "Atenção" ), Ret(x_cValRet, oForm_Choise,0), ) FONT oFont1 Message "Clicando aqui, vai sair da janela" oBtn5:SETCOLOR( 0, 14342874 ) SET MESSAGE OF oForm_Choise TO "Escolha uma das opções oferecidas" Return .t. *-------------------------------------------* * * Define a Funcao Ret que fecha a janela da escolha e retorna o valor correspondente a opção escolhida * * ATLfuncoes 05/12/2013 - 20:51:52 Everton * *----------------------------------------------------------* Static Function Ret(Ret_Func, oForm_Choise, nNuNumer ) oForm_Choise:end() Ret_Func := str(nNuNumer) Return Ret_Func Agradeço antecipadamente. Att. Everton Quote Link to comment Share on other sites More sharing options...
Erciley Junior Posted December 10, 2013 Report Share Posted December 10, 2013 Olá, se entendi bem..... Em todo lugar que você passa a variável Ret_Func como parâmetro, você deve passá-la como "referência". Ou seja: Troque isso: Ret( Ret_Func , oForm_Choise,4) por isso: Ret( @Ret_Func , oForm_Choise,4) Quote Link to comment Share on other sites More sharing options...
evertonlb Posted December 10, 2013 Author Report Share Posted December 10, 2013 Sim Erciley, faço isso... o ideal era algo como Ret_Func := WinEscolha(.......) att. Quote Link to comment Share on other sites More sharing options...
evertonlb Posted December 10, 2013 Author Report Share Posted December 10, 2013 Ah tah... entendi o que tu sugeriu.. mas acabei de fazer isso tambem, mas sempre volta vazio!!! Quote Link to comment Share on other sites More sharing options...
Erciley Junior Posted December 10, 2013 Report Share Posted December 10, 2013 Olá Everton. No ou nos pontos onde chama a função Ini_oForm_Choise( Ret_Func.....), você está fazendo isso também? ou seja Ini_oForm_Choise( @Ret_Func...........) Quote Link to comment Share on other sites More sharing options...
evertonlb Posted December 10, 2013 Author Report Share Posted December 10, 2013 Sim tambem... veja..: Ret_Func := Space(01) Escolha_Win( @Ret_Func,; "Este registro ja existe:", "Codigo...: ", "Data........: " ,; "Qual a atitude a tomar com estes dados?",; "Excluir", "Imagens\16\Cancela.bmp","Clique aqui para EXCLUIR o registro atual",; "Alterar", "Imagens\16\Trabalha.bmp","Clique aqui para ALTERAR os dados do registro atual",; "Cancelar","Imagens\16\SAIR.bmp", "Clique aqui para RETORNAR sem alterar os dados do registro atual" ) ?? Ret_Func att. Quote Link to comment Share on other sites More sharing options...
vagner Posted December 10, 2013 Report Share Posted December 10, 2013 Olá, Coloque nos botões o seguinte :Action(Ret_Func := Ret(Ret_Func)) Quote Link to comment Share on other sites More sharing options...
vagner Posted December 10, 2013 Report Share Posted December 10, 2013 Function Ini_oForm_Choise(Ret_Func, x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) @ 1, 6 GROUP oGrp1 TO 99, 514 LABEL "" PIXEL; OF oForm_Choise COLOR 0, 15790320 FONT oFont1 @ 12, 10 SAY oSay1 VAR x_c_Linha1 SIZE 492, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 31, 10 SAY oSay2 VAR x_c_Linha2 SIZE 490, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 50, 10 SAY oSay3 VAR x_c_Linha3 SIZE 487, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 69, 11 SAY oSay4 VAR x_c_Linha4 SIZE 491, 16 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 if CpBt1 <> NIL @ 103, 6 BTNBMP oBtn1 Prompt CpBt1; FILE Img1 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION( Ret_Func := Ret(Ret_Func, oForm_Choise,1)) FONT oFont1 message Tool1 oBtn1:SETCOLOR( 0, 14342874 ) endif * if CpBt2 <> NIL @ 103, 106 BTNBMP oBtn2 Prompt CpBt2; FILE Img2 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION( Ret_Func := Ret(Ret_Func, oForm_Choise,2)) FONT oFont1 message Tool2 oBtn2:SETCOLOR( 0, 14342874 ) endif * if CpBt3 <> NIL @ 103, 206 BTNBMP oBtn3 Prompt CpBt3; FILE Img3 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION( Ret_Func := Ret(Ret_Func, oForm_Choise,3)) FONT oFont1 message Tool3 oBtn3:SETCOLOR( 0, 14342874 ) endif * if CpBt4 <> NIL @ 103, 306 BTNBMP oBtn4 Prompt CpBt4; FILE Img4 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION( Ret_Func := Ret(Ret_Func, oForm_Choise,4)) FONT oFont1 message Tool4 oBtn4:SETCOLOR( 0, 14342874 ) endif * @ 103, 434 BTNBMP oBtn5 Prompt "Sair"; FILE "Imagens\16\EXIT.bmp" SIZE 80, 26 PIXEL LEFT; OF oForm_Choise ACTION if( MsgInfo( "Tem certeza que deseja sair sem escolher nenhuma das opções?", "Atenção" ), Ret(x_cValRet, oForm_Choise,0), ) FONT oFont1 Message "Clicando aqui, vai sair da janela" oBtn5:SETCOLOR( 0, 14342874 ) SET MESSAGE OF oForm_Choise TO "Escolha uma das opções oferecidas" Return .t. *-------------------------------------------* * * Define a Funcao Ret que fecha a janela da escolha e retorna o valor correspondente a opção escolhida * * ATLfuncoes 05/12/2013 - 20:51:52 Everton * *----------------------------------------------------------* Static Function Ret(Ret_Func, oForm_Choise, nNuNumer ) oForm_Choise:end() Ret_Func := str(nNuNumer) Return Ret_Func Quote Link to comment Share on other sites More sharing options...
evertonlb Posted December 10, 2013 Author Report Share Posted December 10, 2013 Cara... deve ter alguma coisa errada... já tentei de 100 maneiras diferentes, inclusive da maneira indicada pelo Vagner e nada.. continua voltando vazio!!! att. Quote Link to comment Share on other sites More sharing options...
evertonlb Posted December 11, 2013 Author Report Share Posted December 11, 2013 Vejam.. a variável vai pra função, recebe o valor, checo dentro da função se o valor foi atribuído.. ta tudo certo.. mas na hora de voltar é que não volta!! Alias, volta ' " " '. Quote Link to comment Share on other sites More sharing options...
Erciley Junior Posted December 11, 2013 Report Share Posted December 11, 2013 Nesta função que você seleciona as opções, cadê a criação da DIALOG? Deve ser este seu problema..... Posta este trecho todo, modificado para vermos (passando a variável como referência), se for o caso... Quote Link to comment Share on other sites More sharing options...
evertonlb Posted December 11, 2013 Author Report Share Posted December 11, 2013 Bom Erciley.. Já fiz algumas tentativas, por isso algumas coisas estão diferentes desde a primeira postagem, mas vai lá.. o código todo agora tá assim!! *----------------------------------------------------------* Function Escolha_Win( x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) local oGrp1,; oSay1, oSay2, oSay3, oSay4,; oBtn1, oBtn2, oBtn3, oBtn4, oBtn5 private cLetRet DEFINE FONT oFONT1 NAME "Ms Sans Serif" SIZE 0, -12 DEFINE FONT oFONT2 NAME "Arial" SIZE 0, -13 Define DIALOG oForm_Choise TITLE "Janela de Opções" STYLE 4; FROM 194, 371 to 380, 895 PIXEL COLOR 0, 15790320 ACTIVATE DIALOG oForm_Choise ON INIT Ini_oForm_Choise(x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) Return NIL //---------------------------------------------------------------------------- Function Ini_oForm_Choise(x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) @ 1, 6 GROUP oGrp1 TO 99, 514 LABEL "" PIXEL; OF oForm_Choise COLOR 0, 15790320 FONT oFont1 @ 12, 10 SAY oSay1 VAR x_c_Linha1 SIZE 492, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 31, 10 SAY oSay2 VAR x_c_Linha2 SIZE 490, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 50, 10 SAY oSay3 VAR x_c_Linha3 SIZE 487, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 69, 11 SAY oSay4 VAR x_c_Linha4 SIZE 491, 16 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 if CpBt1 <> NIL @ 103, 6 BTNBMP oBtn1 Prompt CpBt1; FILE Img1 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION( cLetRet := "A", oForm_Choise:end() ) FONT oFont1 message Tool1 oBtn1:SETCOLOR( 0, 14342874 ) endif * if CpBt2 <> NIL @ 103, 106 BTNBMP oBtn2 Prompt CpBt2; FILE Img2 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret( oForm_Choise, "B" ) FONT oFont1 message Tool2 oBtn2:SETCOLOR( 0, 14342874 ) endif * if CpBt3 <> NIL @ 103, 206 BTNBMP oBtn3 Prompt CpBt3; FILE Img3 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret( oForm_Choise,"C" ) FONT oFont1 message Tool3 oBtn3:SETCOLOR( 0, 14342874 ) endif * if CpBt4 <> NIL @ 103, 306 BTNBMP oBtn4 Prompt CpBt4; FILE Img4 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret( oForm_Choise,"D" ) FONT oFont1 message Tool4 oBtn4:SETCOLOR( 0, 14342874 ) endif * @ 103, 434 BTNBMP oBtn5 Prompt "Sair"; FILE "Imagens\16\EXIT.bmp" SIZE 80, 26 PIXEL LEFT; OF oForm_Choise ACTION if( MsgInfo( "Tem certeza que deseja sair sem escolher nenhuma das opções?", "Atenção" ), Ret(oForm_Choise,"E"), ) FONT oFont1 Message "Clicando aqui, vai sair da janela" oBtn5:SETCOLOR( 0, 14342874 ) SET MESSAGE OF oForm_Choise TO "Escolha uma das opções oferecidas" Return cLetRet *-------------------------------------------* * * Define a Funcao Ret que fecha a janela da escolha e retorna o valor correspondente a opção escolhida * * ATLfuncoes 05/12/2013 - 20:51:52 Everton * *---------------------------------------------------------- Static Function Ret(oForm_Choise, cLetRet ) oForm_Choise:end() Return cLetRet Fiz um teste com outra função.. só voltando o valor, sem montar DIALOG, sem botões, sem nada.. e o valor volta certo, mas nesta não... Acho que talvez seja por usar outra função dentro da ESCOLHA_WIN() para atribuir o valor e fechar a DIALOG dos botões. No Action do botão teria como dar um "return cOpcao"? Eu tentei mas da uma mensagem de erro na compilação! Acho que se conseguisse isso deveria dar certo! Deveriaser nesta ordem: Clicar no botão, fecha a DIALOG e retorno o valor Att. Quote Link to comment Share on other sites More sharing options...
Erciley Junior Posted December 11, 2013 Report Share Posted December 11, 2013 Rapaz, do jeito que está não vai funcionar mesmo. Tem várias outras formas de fazer, mas assim, só não falo que tenho certeza que está certo pois não testei, mas eu tenho, hehehe. Só troque o código por isso: *----------------------------------------------------------* Function Escolha_Win( x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) local oGrp1,; oSay1, oSay2, oSay3, oSay4,; oBtn1, oBtn2, oBtn3, oBtn4, oBtn5 LOCAL cLetRet DEFINE FONT oFONT1 NAME "Ms Sans Serif" SIZE 0, -12 DEFINE FONT oFONT2 NAME "Arial" SIZE 0, -13 Define DIALOG oForm_Choise TITLE "Janela de Opções" STYLE 4; FROM 194, 371 to 380, 895 PIXEL COLOR 0, 15790320 ACTIVATE DIALOG oForm_Choise ON INIT Ini_oForm_Choise( @cLetRet , x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) ?'TESTE AKI DA VARIÁVEL ',cLetRet Return NIL //---------------------------------------------------------------------------- Function Ini_oForm_Choise( cLetRet , x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) @ 1, 6 GROUP oGrp1 TO 99, 514 LABEL "" PIXEL; OF oForm_Choise COLOR 0, 15790320 FONT oFont1 @ 12, 10 SAY oSay1 VAR x_c_Linha1 SIZE 492, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 31, 10 SAY oSay2 VAR x_c_Linha2 SIZE 490, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 50, 10 SAY oSay3 VAR x_c_Linha3 SIZE 487, 18 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 @ 69, 11 SAY oSay4 VAR x_c_Linha4 SIZE 491, 16 PIXEL; OF oGrp1 COLOR 0, 15790320 FONT oFont2 if CpBt1 <> NIL @ 103, 6 BTNBMP oBtn1 Prompt CpBt1; FILE Img1 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret( oForm_Choise, "A" , @cLetRet ) FONT oFont1 message Tool1 oBtn1:SETCOLOR( 0, 14342874 ) endif * if CpBt2 <> NIL @ 103, 106 BTNBMP oBtn2 Prompt CpBt2; FILE Img2 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret( oForm_Choise, "B" , @cLetRet ) FONT oFont1 message Tool2 oBtn2:SETCOLOR( 0, 14342874 ) endif * if CpBt3 <> NIL @ 103, 206 BTNBMP oBtn3 Prompt CpBt3; FILE Img3 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret( oForm_Choise,"C" , @cLetRet) FONT oFont1 message Tool3 oBtn3:SETCOLOR( 0, 14342874 ) endif * if CpBt4 <> NIL @ 103, 306 BTNBMP oBtn4 Prompt CpBt4; FILE Img4 SIZE 100, 26 PIXEL LEFT; OF oForm_Choise ACTION Ret( oForm_Choise,"D" , @cLetRet ) FONT oFont1 message Tool4 oBtn4:SETCOLOR( 0, 14342874 ) endif * @ 103, 434 BTNBMP oBtn5 Prompt "Sair"; FILE "Imagens\16\EXIT.bmp" SIZE 80, 26 PIXEL LEFT; OF oForm_Choise ACTION if( MsgInfo( "Tem certeza que deseja sair sem escolher nenhuma das opções?", "Atenção" ), Ret(oForm_Choise,"E" , @cLetRet ), ) FONT oFont1 Message "Clicando aqui, vai sair da janela" oBtn5:SETCOLOR( 0, 14342874 ) SET MESSAGE OF oForm_Choise TO "Escolha uma das opções oferecidas" Return *-------------------------------------------* * * Define a Funcao Ret que fecha a janela da escolha e retorna o valor correspondente a opção escolhida * * ATLfuncoes 05/12/2013 - 20:51:52 Everton * *---------------------------------------------------------- Static Function Ret(oForm_Choise, cOpcao , cLetRet ) cLetRet:=cOpcao oForm_Choise:end() Return Quote Link to comment Share on other sites More sharing options...
evertonlb Posted December 11, 2013 Author Report Share Posted December 11, 2013 Ai Erciley.. obrigado pelas dicas... Fiz o teste com o código que tu mandou, a princípio não funcionou, mas ai a variável que tinha inicializado como Local, coloquei como Private e o Return que estava NIL, mandei retornar a variável... ficou assim: private cLetRet DEFINE FONT oFONT1 NAME "Ms Sans Serif" SIZE 0, -12 DEFINE FONT oFONT2 NAME "Arial" SIZE 0, -13 Define DIALOG oForm_Choise TITLE "Janela de Opções" STYLE 4; FROM 194, 371 to 380, 895 PIXEL COLOR 0, 15790320 ACTIVATE DIALOG oForm_Choise ON INIT Ini_oForm_Choise( @cLetRet, x_c_Linha1, x_c_Linha2, x_c_Linha3, x_c_Linha4,; CpBt1, Img1, Tool1,; CpBt2, Img2, Tool2,; CpBt3, Img3, Tool3,; CpBt4, Img4, Tool4 ) Return cLetRet Agora ta voltando o valor certinho... Obrigado pelo tempo que você e o Vagner gastaram em me ajudar... Att. Everton Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.