ampersand

ampersand

Postby jds » Tue Mar 21, 2023 5:32 pm

I am a non professional user (retired) of fivewin and make only programs for our local food bank
I am still programming like I did it in the nineties
How can I, in the example of a part of a procedure, after the 'say' and 'get' commands become the real record names?

select products
a=5
b=5.8
set filter to products->niet=" "
goto top
do while .NOT. eof()
cnaam2=TRIM(products->naam)
nalias=TRIM(products->alias)
@ a,5 say cnaam OF oDlg FONT oFont
@ b,12 get nalias OF oDlg SIZE 20,11 picture "999" FONT oFont
skip 1
a=a+1
b=b+1.15
enddo
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby Marc Venken » Tue Mar 21, 2023 7:33 pm

Hallo Jose,

Can you tell us a bit more what you are trying to do ? There are many samples out here and so we can point you to one of them in order to have a starting point.

One of the most complete and usable samples is Yunus.

Btw : Where in Belgium are you from ? I'm from Limburg.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: ampersand

Postby jds » Tue Mar 21, 2023 9:01 pm

Dag Marc,
Ik woon in Harelbeke WVL en beheer de werking van de lokale voedselbank.
De bedoeling is een manier te vinden om de beschikbare voedingproducten opgeslagen in een bestand products.dbf op te nemen in het verkoop.dbf bestand dat de gratis afgeleverde producten per klant registreert. Voor het ogenblik heb ik een werkende procedure voor de verkoopprocedure die ik evenwel in de broncode telkens moet aanpassen als er producten bijkomen. Eenvoudiger zou zijn die te kunnen inbrengen in de verkoop procedure door verwijzing naar het producten bestand products.dbf.
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby Marc Venken » Tue Mar 21, 2023 9:43 pm

Jose,

The sample Yunus.prg in the sample dir can give you a working point. There is a Client, Item and invoice database. See the Client and use the products to add to the invoice. I think that it is almost the same idea.

Mocht Yunus niet duidelijk zijn (of beschikbaar), geef dan even een seintje...
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: ampersand

Postby jds » Tue Mar 21, 2023 10:26 pm

Hey Marc
I compiled the yunus.prg and of course it is a beautiful modern version of my nineties way of programming. I remember me that it was possible in the post Clipper era to transform a variable into his real record name by adding somewhere the ampersand (&) sign?
Don't you have somewhere an example of that old fashion way of programming?
José Deschutter (jds)
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby Jimmy » Wed Mar 22, 2023 6:37 am

hi
jds wrote:I remember me that it was possible in the post Clipper era to transform a variable into his real record name by adding somewhere the ampersand (&) sign?

what you mean is a "Macro" where you use "&" (Ampersand)
Code: Select all  Expand view  RUN
  // variable
   cDBF := "D:\WORK\CUSTOMER.DBF"
   // use Macro
   USE &cDBF
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: ampersand

Postby jds » Wed Mar 22, 2023 9:41 am

Hi Jimmy
How can I apply this way of program on my example (part of procedure) in top of my early post
Thanks
José
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby Marc Venken » Wed Mar 22, 2023 9:54 am

Some Code snippets from early FW ... Maybe some items that are usefull

Code: Select all  Expand view  RUN

function makevar(cDbf)
   for i = 1 to &cDbf->(fcount())
      mveld = &cDbf->(fieldname(i))
      mtemp = "M_"+&cDbf->(fieldname(i))
       &mtemp = mveld
   next
return(.t.)

function Stockchange(cVeld,cCode,cActie,nStockaantal)
   cCode = alltrim(cCode)
   If artplus->(dbseek(cCode))
      cStockAlias = "artplus"
   elseif artikel->(dbseek(cCode))
      cStockAlias = "artikel"
   else
      Info("Bij artikel "+cCode+" kan de stock van "+cActie+" "+str(nStockaantal)+" niet worden weggeschreven")
      return
   endif
   rec_lock("&cStockalias")
   DO case
      CASE cVeld = "MAG"
         If cActie = "RESET"
            &cStockalias->stockmag = &cStockalias->stockmag + nStockaantal
         else
            &cStockalias->stockmag = &cStockalias->stockmag + if(cActie = "PLUS",nStockaantal,-nStockaantal)
         EndIF
      CASE cVeld = "KLA"
         &cStockalias->stockkla = &cStockalias->stockkla + if(cActie = "PLUS",nStockaantal,-nStockaantal)
      CASE cVeld = "LEV"
         &cStockalias->stocklev = &cStockalias->stocklev + if(cActie = "PLUS",nStockaantal,-nStockaantal)
      CASE cVeld = "RES"
         &cStockalias->stockres = &cStockalias->stockres + if(cActie = "PLUS",nStockaantal,-nStockaantal)
   Endcase
   rec_unlock("&cStockalias")
return

function showReservatie(cDoc)
   select factart
   set index to factart
   if dbseek(cDoc)
   //index on factart->magazijn to c:\marc\tempres while factart->levbon = cDoc
   /*
   index on factart->(recno()) to c:\marc\tempres while factart->levbon = cDoc
   set index to c:\marc\tempres
   factart->(dbgotop())
   If factart->(flock())
      nProcess:=0
      DO while !factart->(eof())
         If len(alltrim(factart->refnummer)) > 9
            cAlias = "ARTPLUS"
         else
            cAlias = "ARTIKEL"
         endif
         &cAlias->(dbseek(factart->refnummer))
         factart->stockmag = &cAlias->stockmag
         factart->stocklev = &cAlias->stocklev
         factart->(dbskip())
         nProcess++
      EndDO
      msginfo("process"+str(nProcess,6))
   else
      msginfo("Geen Flock op het bestand : Factart")
   endif
   factart->(dbunlock())
   factart->(dbgotop())
   */

   else
     msginfo("Document niet gevonden")
   endif
return

   for i = 1 to nElement

     cI=PADL(i,2,'0')
     //cMaat&cI = space(4)
     cMaat&cI = stzero(aMag[i],4,0)
     REDEFINE say oBtnKnop&cI prompt aMaten[i] ID 34+(2*I) OF oDlgstock
     REDEFINE say oBtnMag&cI prompt stzero(aMag[i],3,0) ID 134+(2*I) OF oDlgstock
     REDEFINE say oBtnKla&cI prompt stzero(aKla[i],3,0) ID 234+(2*I) OF oDlgstock
     REDEFINE say oBtnRes&cI prompt stzero(aRes[i],3,0) ID 334+(2*I) OF oDlgstock
     REDEFINE say oBtnLev&cI prompt stzero(aLev[i],3,0) ID 434+(2*I) OF oDlgstock
     REDEFINE GET omaat&ci VAR cmaat&ci picture '999999' ID 1999+i OF oDlgstock font oFont1

   next

function Pullout(cDbf,cIndex,cZoek,cVeld)
   local cReturn:="Geen Data"

   use &cDbf index &cIndex shared New
   if &cDbf->(dbseek(cZoek))
      if cDbf = "HISTORIEK"
         cReturn = dtoc(historiek->datum)+" -> "+alltrim(cValtoChar(historiek->eenh_prijs))+" Code -> ( "+historiek->prijscode+" )"
      else
         cReturn = alltrim(cValtoChar(&cDbf->&cVeld))
      endif
   endif
   &cDbf->(dbcloseArea())

return (cReturn)

   for i = nElement+1 to 16  // clear the rest out
      cI=PADL(i,2,'0')
      REDEFINE say oBtnMag&cI prompt "" ID 134+(2*I) OF oDlgstock
      REDEFINE say oBtnKla&cI prompt "" ID 234+(2*I) OF oDlgstock
      REDEFINE say oBtnRes&cI prompt "" ID 334+(2*I) OF oDlgstock
      REDEFINE say oBtnLev&cI prompt "" ID 434+(2*I) OF oDlgstock
      REDEFINE say oBtnMin&cI prompt "" ID 534+(2*I) OF oDlgstock update
   next




 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: ampersand

Postby jds » Wed Mar 22, 2023 10:41 am

Thank you Marc, I try to do it that what.
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby jds » Mon Mar 27, 2023 3:02 pm

Hi Marc,
Better explained:
How to transform within a do while procedure (file A) each appealed field into his real fieldname so that I can use this fieldname into an other file B.
kind regards
José
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby jds » Mon Mar 27, 2023 3:08 pm

example:
select products
goto top
do while .NOT. eof()
cnaam=TRIM(products->naam) to transform in his real fieldname

select sales
append blank
replace sales->fieldname with ....

select products
skip 1

enddo
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby Marc Venken » Tue Mar 28, 2023 7:18 pm

Jose,

I'm still not sure what you try to do
If you use aliases, maybe it is better ? I don't think that you wanne go into database object. Here a code that look like yours.

Please feel free to post if I understood you wrong.

Code: Select all  Expand view  RUN
         netopen("artikel","artcode","arttemp")
          netopen("nofoto","tag01","nofototemp")
          netopen("webshop","brandid","webtemp")
          // ....
          if webtemp->(flock())
            webtemp->(dbgotop())
            do while !webtemp->(eof())
              lArtFound = .f.
              nTel1++
              cData = upper(webtemp->brandid)
              if nofototemp->(dbseek(cData))
                replace webtemp->new_bruto with nofototemp->new_bruto
                replace webtemp->new_bruto with nofototemp->bruto
                replace webtemp->new_date with nofototemp->new_date
              else
                nofototemp->(dbappend())
                replace nofototemp->new_bruto with 1
                /// ...
              endif
              webtemp->(dbskip())
            enddo
          endif
          msginfo("Update van brandid gegevens : "+str(nTel1)+CRLF+"Update van Server brandid gegevens : "+str(nTelServer))
          // .....
 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: ampersand

Postby jds » Wed Mar 29, 2023 12:38 pm

Hi Marc,
It is possible that I want to obtain the impossible.
I want to use the existing name of some records in one file (by doing a do while procedure) to use/call them as existing fieldname in an other file....
Kind regards
José
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: ampersand

Postby leandro » Wed Mar 29, 2023 1:49 pm

An idea
Code: Select all  Expand view  RUN

cThefuncion := "strinFunc()"
cVar := "{|| "+cThefuncion+" }"
EVAL( &cVar )
 

I hope it helps you
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1688
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 67 guests