FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ampersand
Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
ampersand
Posted: Tue Mar 21, 2023 05: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

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: ampersand
Posted: Tue Mar 21, 2023 07: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.08 with Harbour
Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: ampersand
Posted: Tue Mar 21, 2023 09: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.

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: ampersand
Posted: Tue Mar 21, 2023 09: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.08 with Harbour
Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: ampersand
Posted: 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)

Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: ampersand
Posted: Wed Mar 22, 2023 06: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 (fw): Select all Collapse
   // variable
   cDBF := "D:\WORK\CUSTOMER.DBF"
   // use Macro
   USE &cDBF
greeting,

Jimmy
Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: ampersand
Posted: Wed Mar 22, 2023 09: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é

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: ampersand
Posted: Wed Mar 22, 2023 09:54 AM
Some Code snippets from early FW ... Maybe some items that are usefull
Code (fw): Select all Collapse
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.08 with Harbour
Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: ampersand
Posted: Wed Mar 22, 2023 10:41 AM

Thank you Marc, I try to do it that what.

Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: ampersand
Posted: Mon Mar 27, 2023 03: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é

Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: ampersand
Posted: Mon Mar 27, 2023 03: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

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: ampersand
Posted: Tue Mar 28, 2023 07: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 (fw): Select all Collapse
          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.08 with Harbour
Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: ampersand
Posted: 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é

Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: ampersand
Posted: Wed Mar 29, 2023 01:49 PM
An idea
Code (fw): Select all Collapse
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

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]

Continue the discussion