Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: David Kurniawan
  Where is David Kurniawan?
 Semarang
 Indonesia
 David Kurniawan
 Tags
Subject: RE: ask deferent between use FLUSH or not
Thread ID: 373419 Message ID: 373480 # Views: 50 # Ratings: 3
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Friday, March 22, 2013 1:01:13 PM         
   


> Dear Expert
>
>
> May i know
> 1. between use FLUSH after insert/edit/delete with not use FLUSH
> 2. between = operator and == operator
> and give me an example used above
>
>
>
> BR
>
> DAVID KURNIAWAN
> mamamia

1) I wouldn't comment on that. I don't remember I needed flush in my applications ever (only back in fox2x days).
2) Is a very good question. I think majority of VFP developers don't really know the behavior differences of = and ==.

Basically = means 'equal or starts with' and == means 'exactly equal' depending on SET EXACT and SET ANSI settings, as well as where they are used (behavior is not the same with SQL commands and the rest). I created some sort of truth table for you to understand the difference by example (see below). Note that in case of SQL these are the differences:

-SET EXACT have no effect,
-Left and Right operands are interchangeable ( a=b means b=a ),

and == doesn't care about SET EXACT/ANSI setting (but their behavior is still different depending that they are used with SQL or not).


Close Databases All
Select Padr(Cust_ID,10) As Cust_ID From _samples+'data\Customer' Into Cursor xBaseTest nofilter
Use In Select('customer')
Select xBaseTest
Index On Cust_ID Tag Cust_ID
Set Order To 0

Create Cursor TestResults (TestCase c(100), SetExact c(3), SetAnsi c(3), Result c(5))

TestEquality('TEST', 'T')
TestEquality('TEST  ', 'TEST')
TestEquality('TEST ', 'TEST ')

Locate
lSet = .F.
Browse Name "myBrowse" ;
  Title 'Comparison of = to == in xBase and Sql' ;
  When setGrid()

Procedure TestEquality(tcLeft, tcRight)
  Set Exact Off && default
  InsertEqualities(m.tcLeft, m.tcRight)
  Set Exact On
  InsertEqualities(m.tcLeft, m.tcRight)
Endproc

Procedure InsertEqualities(m.tcLeft, m.tcRight)
  Set Ansi Off && default
  InsertEquality(m.tcLeft, m.tcRight)
  InsertSelectEqualities()
  Set Ansi On
  InsertEquality(m.tcLeft, m.tcRight)
  InsertSelectEqualities()
Endproc

Procedure InsertSelectEqualities()
  InsertSelectCases('ALF')
  InsertSelectCases('ALFKI')
  InsertSelectCases(Padr('ALFKI', Fsize('cust_id', 'xBaseTest')))
Endproc

Procedure InsertEquality(tcLeft, tcRight)
  Insert Into TestResults (TestCase, SetExact, SetAnsi, Result) ;
    values;
    ( Textmerge('"<< m.tcLeft >>" = "<< m.tcRight >>"') , ;
    Set("Exact"), Set("Ansi"), ;
    Iif( m.tcLeft = m.tcRight, 'TRUE', 'FALSE' ) )

  Insert Into TestResults (TestCase, SetExact, SetAnsi, Result) ;
    values;
    ( Textmerge('"<< m.tcRight >>" = "<< m.tcLeft >>"') , ;
    Set("Exact"), Set("Ansi"), ;
    Iif( m.tcRight = m.tcLeft, 'TRUE', 'FALSE' ) )

  Insert Into TestResults (TestCase, SetExact, SetAnsi, Result) ;
    values;
    ( Textmerge('"<< m.tcLeft >>" == "<< m.tcRight >>"') , ;
    Set("Exact"), Set("Ansi"), ;
    Iif( m.tcLeft == m.tcRight, 'TRUE', 'FALSE' ) )

  Insert Into TestResults (TestCase, SetExact, SetAnsi, Result) ;
    values;
    ( Textmerge('"<< m.tcRight >>" == "<< m.tcLeft >>"') , ;
    Set("Exact"), Set("Ansi"), ;
    Iif( m.tcRight == m.tcLeft, 'TRUE', 'FALSE' ) )
Endproc

Procedure InsertSelectCases(tcValue)
  InsertSelectCase( Textmerge( 'xBaseTest.Cust_id = "<< m.tcValue >>"' ) )
  InsertSelectCase( Textmerge( '"<< m.tcValue >>" = xBaseTest.Cust_id' ) )
  InsertSelectCase( Textmerge( 'xBaseTest.Cust_id == "<< m.tcValue >>"' ) )
  InsertSelectCase( Textmerge( '"<< m.tcValue >>" == xBaseTest.Cust_id' ) )
Endproc

Procedure InsertSelectCase(tcSelectWhere)
  Local Array laCount[1]
  Select Count(*) From xBaseTest Where &tcSelectWhere Into Array laCount
  Insert Into TestResults (TestCase, SetExact, SetAnsi, Result) ;
    values;
    ( m.tcSelectWhere , Set("Exact"), Set("Ansi"), Iif( laCount[1] > 0, 'TRUE', 'FALSE' ) )
Endproc

Procedure setGrid
  If !m.lSet
    With m.myBrowse
      .FontName = 'Courier New'
      .DeleteMark = .F.
      .RecordMark = .F.
      .Height = 400
      .Width = 600
      .SetAll("DynamicBackColor", "(iif(Result='TRUE',0x80FF80,0xFFFFFF))")
      .Columns(2).DynamicBackColor = "(Iif(SetExact='ON',0xFF00, 0xFF))"
      .Columns(3).DynamicBackColor = "(Iif(SetAnsi ='ON',0xFF00, 0xFF))"
    Endwith
    lSet=.T.
  Endif
Endproc




Cetin Basoz

.Net has got better.Think about moving - check my blog:
My Blog


MongoDb Certified Developer
MongoDb Certified DBA


Support Wikipedia

ENTIRE THREAD

ask deferent between use FLUSH or not Posted by David Kurniawan @ 3/22/2013 6:02:51 AM
RE: ask deferent between use FLUSH or not Posted by llyrad atsituab @ 3/22/2013 6:16:06 AM
RE: ask deferent between use FLUSH or not Posted by Jun Tangunan @ 3/22/2013 6:43:43 AM
RE: ask deferent between use FLUSH or not Posted by David Kurniawan @ 3/22/2013 6:56:09 AM
RE: ask deferent between use FLUSH or not Posted by Jun Tangunan @ 3/22/2013 8:05:52 AM
RE: ask deferent between use FLUSH or not Posted by Cetin Basoz @ 3/22/2013 1:01:13 PM