Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which is better IF (!SEEK(UPPER(expr))
Message
De
14/07/2001 07:25:49
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00530269
Message ID:
00530632
Vues:
18
This message has been marked as the solution to the initial question of the thread.
>I really dont know what will be dragging the whole thing but anyway here is the actual codes
>
>This is the call multiple with diff codes:
>
>	m.narrcode   = "A09SJVADACCT"
>	m.narrdesc   = "Journal Voucher (Many-To-Many A/c.'s), Debit Account Entry Narration"
>
>	m.narration  = "'Accounts J.V. no. ' + ALLTRIM(STR(m.jvno)) + ' dtd. ' + "
>	m.narration  = m.narration + "DTOC(m.jvdt) + '.  ' + strip_crlf(a09sjvad.remarks)"
>
>	m.addremarks = .T.
>	m.befremarks = ""
>	= creamnarr(m.narrcode, m.narrdesc, m.narration, m.addremarks, m.befremarks)
>
>
>
>This is the function:
>
>FUNCTION creamnarr
>	
>	PARAMETERS m.znarrcode, m.znarrdesc, m.znarration, m.zaddremarks, m.zbefremarks
>	
>	
>	PRIVATE ALL LIKE z*
>	
>	
>	m.znarrcode = UPPER(m.znarrcode)
>	
>	IF !SEEK(m.znarrcode)
>		= appendblank()
>		
>		REPLACE a09mnarr.narrcode   WITH UPPER(m.znarrcode), ;
>			a09mnarr.narrdesc        WITH m.znarrdesc, ;
>			a09mnarr.narration       WITH m.znarration, ;
>			a09mnarr.addremarks      WITH m.zaddremarks, ;
>			a09mnarr.befremarks      WITH m.zbefremarks
>		= requiredflds("a09mnarr", .T.)
>	ENDIF
>
>
>
>
>Thanks for replying and what do you feel is the bottleneck.
>
>Regards
>Bhavbhuti

Parameters by default pass by value. As I could see you don't need private there. appendblank() call sounds to be doing an append blank for a new record. If so then :
FUNCTION creamnarr
m.narrcode = UPPER(m.narrcode)
IF !SEEK(m.narrcode)
    insert into (alias()) ;
     (narcode,narrdesc,narration,addremarks,befremarks) ;
     values ;
     (m.narcode,m.narrdesc,m.narration,m.addremarks,m.befremarks)
* or just 'insert into (alias()) from memvar' 
 = requiredflds("a09mnarr", .T.)
ENDIF
Sounds more feasible. Another safer method would be like :
if !seek("A09SJVADACCT",alias(),'narcode') && Otherwise no need for rest ?
  local loRecord
  scatter name loRecord blank && Initialize a blank record as object
  with loRecord && Fill known elements
    .narrcode = "A09SJVADACCT"
    .narrdesc = "Journal Voucher (Many-To-Many A/c.'s), Debit Account Entry Narration"
    *.. other fields
  endwith
  CreamNarr(loRecord)
endif

function CreamNarr
lparameters toRecord
append blank
gather name toRecord 
requiredflds("a09mnarr", .T.)
I assume you have no filter set here. Otherwise seek() would still be fast but might return .f. if that code is not in filtered set. 'Append blank+replace' combination is slower than 'insert into'.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform