Marc Venken wrote:I also don't kill the objects like fonts, oDlg, ... I Mostly just end the program and all this stuff is gone ? At least I think so...
Marc Venken wrote:test1.prg(1714) Warning W0027 Meaningless use of expression ':'
test1.prg(1714) Warning W0027 Meaningless use of expression 'Logical'
test1.prg(1716) Warning W0027 Meaningless use of expression ':'
test1.prg(1716) Warning W0027 Meaningless use of expression 'Logical'
test1.prg(1744) Warning W0001 Ambiguous reference 'DLG'
test1.prg(1757) Warning W0001 Ambiguous reference 'NSIZE'
test1.prg(1758) Warning W0001 Ambiguous reference 'NSIZE'
test1.prg(1823) Warning W0001 Ambiguous reference 'OBTNINDEXES'
function XbrSetupbuttons( oBrw,cData )
local cString:="", nOrder:=0
do case
case upper(oBrw:cAlias) = "BRWDETAIL"
msginfo("Test Editsource")
cString = brwdetail->brwnaam
obrw:gobottom()
nOrder = brwdetail->order + 10
nSize = 100
oBrw:EditSource(.T., "brwnaam,order,size" , { cString,nOrder,nSize })
//cData = brwdetail->brwnaam
//oBrw:add()
//msginfo("BRWDETAIL")
otherwise
oBrw:EditSource(.t.)
endcase
return NIL
Enrico Maria Giordano wrote:Marc Venken wrote:I also don't kill the objects like fonts, oDlg, ... I Mostly just end the program and all this stuff is gone ? At least I think so...
Yes, all the objects are released at the end of the program. The problem arise when you create a resource inside a function and don't release it at the end: if that function is called n times then the resource is allocated n times and released zero times and you will have resource leakage.
EMG
Marc Venken wrote:( 1714 )DEFINE BUTTON OF oBar PROMPT "Filters Uit" RESOURCE "EDIT";
ACTION (oBrw:lGetBar = .F.,oBrw:refresh(),oBrw:setfocus() )
oBrw:lGetBar := .F.
function testapi() // part of code
local cBuffer:=""
local uResponse, cCookies, I, cLink, cUrl,oHttp
do while !webshop->(eof())
... code for filling my API data into cBuffer
msginfo(cBuffer)
oHttp := FWGetOleObject( "WINHTTP.WinHttpRequest.5.1" )
WITH OBJECT oHttp
:SetTimeouts(0, 60000, 30000, 120000)
:Open( "PATCH", cUrl, .f. ) // My Marc seen on Google
:SetRequestHeader( "Accept", "application/json" )
:SetRequestHeader( "Content-Type", "application/json" )
:Send( cBuffer )
:WaitForResponse()
//if :status <> 200
? :Status, :StatusText // 200 OK
//endif
END
webshop->(dbskip())
enddo
RETURN
FUNCTION Main()
LOCAL sys_versie := "Jan 2022 - 01/01"
// more local
PUBLIC lServer := .F.
public SERVER_PATH := "\\CAROLIEN-PC\MARC\"
public LOCAL_PATH := "c:\marc32\"
Public sys_path
Public oGetLev, oClp, hBrw, oArtChanges
DEFINE CLIPBOARD oClp OF oWnd
// ....
RETURN NIL
Marc Venken wrote:In this code, I recently created I wonder if there is a potential risk of failure because the object oHttp is not ended somewhere into the loop ?
If so, there need to be a oHttp:end() afther the END . Is this the correct logic that I need to start using then ?
Marc Venken wrote:test1.prg(72) Warning W0002 Ambiguous reference, assuming memvar 'LSERVER'
Enrico Maria Giordano wrote:Marc Venken wrote:test1.prg(72) Warning W0002 Ambiguous reference, assuming memvar 'LSERVER'
Where the PUBLIC or PRIVATE variable is used you have to use the MEMVAR declaration or the M -> prefix:
MEMVAR lServer
or
M -> lServer
EMG
Perfect master Enrique, this is how I see the VARIABLE STATEMENTS. And so it is written in the CLIPPER 5.3 books and manuals. Perhaps, I have misunderstood something wrong that you wrote. It doesn't matter, you write your programs his way and I write mine. Thank you for the information.
STATIC oWnd, oDlg, oFont, cClrBack, oBold, oMarc, oGet, oArtChanges
FUNCTION Main()
LOCAL oFol, oDlg, oRBar, oMenu, oMenuWnd, oBrush1, ;
oSay1, oBmp, oFont1, oCursor
// code
oMarc:= TMarc():new()
oMarc:aLever = readleveranciers()
SET AUTORDER TO 1
SET CENTURY ON
SET DATE BRITISH
SET TIME FORMAT TO "HH:MM:SS"
SET EPOCH TO YEAR( DATE() ) - 30
SET SOFTSEEK OFF
SET WRAP ON
SETCANCEL( .F. )
SET CONFIRM OFF
SET DELETED ON
SET _3DLOOK ON
SET UNIQUE OFF
SET ESCAPE OFF
SET EXACT ON
SET EXCLUSIVE OFF
SET MULTIPLE OFF
SET AUTORDER TO 1
define font oFontw name "MS Sans Serif" size 0,-50
// more code
ACTIVATE WINDOW oWnd MAXIMIZED
oBrush1:End()
oRBar:End()
oKlant:End()
oRec:End()
RETURN NIL
CLASS TMarc
DATA aMaanden AS ARRAY INIT {"Jan","Feb","Mrt"}
DATA aDbfVelden AS ARRAY INIT {}
DATA aLever AS ARRAY INIT {}
DATA aMerken AS ARRAY INIT readleveranciers("MERKEN")
//DATA aLever AS ARRAY INIT readleveranciers() // Not working
DATA aStates AS ARRAY INIT { { } } // state 0 defined as empty
DATA name INIT "Just a Name"
METHOD NEW
ENDCLASS
METHOD NEW CLASS TMarc
SET AUTORDER TO 1
SET CENTURY ON
SET DATE BRITISH
SET TIME FORMAT TO "HH:MM:SS"
SET EPOCH TO YEAR( DATE() ) - 30
SET SOFTSEEK OFF
SET WRAP ON
SETCANCEL( .F. )
SET CONFIRM OFF
SET DELETED ON
SET _3DLOOK ON
SET UNIQUE OFF
SET ESCAPE OFF
SET EXACT ON
SET EXCLUSIVE OFF
SET MULTIPLE OFF
SET AUTORDER TO 1
define font oFontw name "MS Sans Serif" size 0,-50
RETURN SELF
function ReadLeveranciers(cType) // Steek leverancier, Code en Tag in Array
local aDbf := {}
local c, aDir
DEFAULT cType := "ALL"
Minfilesize:= 1
netopen("Lever")
//gDBEVAL( { || AAdd( aDbf, FIELD->naam_1 )} )
do case
case cType = "ALL"
DBEVAL( { || AAdd( aDbf, {FIELD->klant_nr,FIELD->naam_1,FIELD->tag} )} )
case cType = "MERKEN"
DBEVAL( { || AAdd( aDbf, {FIELD->klant_nr,FIELD->naam_1,FIELD->tag} )} )
endcase
//ASORT(aDbf, , , { | x,y | x[2] > y[2] } ) // Z->A 2 veld
ASORT(aDbf, , , { | x,y | x[2] < y[2] } ) // A->Z 2 veld
close lever
return aDbf
If you use a Object, and want to see it everywhere, you will use the public not ?
#include "fivewin.ch"
// Class for user
Class TUser
data name as char
method new
Endclass
Method new() Class TUser
::name:=""
Return self
//------------------------------//
// Create a function. Functions can be called from anywhere in the program.
Function User()
static oUser
if oUser == nil
oUser:= TUser():new() // instantiate the object
endif
Return oUser
You can then do this from anywhere:
User():name:= "JBott" // assign a value
// And call this from anywhere in the program
msgInfo(User():Name, "User Name") // returns JBott
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 13 guests