The word Macro generates following code to do search and "REPLACE"
With Selection.Find
.Text = "findword"
.Replacement.Text = "replaceword"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
The above will not work in Foxpro, Foxpro use positional parameters
Function Execute([FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl]) As Boolean
To use in Foxpro, we have to provide all paramters in right sequence till "ReplaceWith". We can omit rest of the parameters
Const wdFindContinue = 1
oword.Selection.Find.Execute(tcOriginal, .f., .f., .f., .f., .f., .t., wdFindContinue, .f., tcReplace)
Wednesday, August 13, 2008
Wednesday, August 6, 2008
SYS(987) Foxpro
Foxpro SYS(987) can be used to return remote Varchar data as ANSI for use with Memo fields.
Remote data with varchar fields in foxpro displays square box between each characters

By setting SYS(987, .T.) the data will be in ANSI format.
The above data now displayed as
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
Remote data with varchar fields in foxpro displays square box between each characters

By setting SYS(987, .T.) the data will be in ANSI format.
The above data now displayed as
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
Labels:
Foxpro
Tuesday, July 29, 2008
Open cash register from DOS
type "copy con: open.txt" and press ENTER
press ALT key and hold it
type "27" on your numeric keypad (Numeric Keypad not one above letters )
release ALT key
type "p07y" (small "p" zero seven and small "y"! without quotes)
type Ctrl-z and then Enter
To open the cash register
copy open.txt LPT1:
press ALT key and hold it
type "27" on your numeric keypad (Numeric Keypad not one above letters )
release ALT key
type "p07y" (small "p" zero seven and small "y"! without quotes)
type Ctrl-z and then Enter
To open the cash register
copy open.txt LPT1:
Labels:
Miscellaneous
Wednesday, July 9, 2008
XP SP3 install - Access Denied Error
Windows Update keeps failing on SP3 update with "Access Denied" error. Searching online found this blog.
http://fastest963windows.blogspot.com/2008/05/before-installing-windows-xp-sp3-
access.html
http://fastest963windows.blogspot.com/2008/05/before-installing-windows-xp-sp3-
access.html
Labels:
xp
Friday, June 27, 2008
Generate Create Script from existing table in Foxpro
Generate Create Script from existing table in Foxpro
Following code generates sql create table script for table or cursor in current workspace.
FUNCTION GenerateCreateScript
LPARAMETERS tcCursor
LOCAL ARRAY aa[1]
LOCAL lcAlias, lcCursor, lnFields, lcsql, lcfield, lcType, lnlen, lnDecimal, lnI
lcAlias = ALIAS()
IF EMPTY(lcAlias)
RETURN ''
ENDIF
IF EMPTY(tcCursor) OR VARTYPE(tcCursor) # 'C'
lcCursor = SYS(2015)
ELSE
lcCursor = tcCursor
ENDIF
lnFields = AFIELDS(aa)
lcsql = [ create cursor ] + lcCursor + [ (]
FOR lnI = 1 TO lnFields
lcfield = aa[lni, 1]
lcType = aa[lni, 2]
lnlen = aa[lni, 3]
lnDecimal = aa[lni, 4]
lcsql = lcsql + lcfield + ' ' + lcType + [(] + TRANSFORM(lnlen)
IF lnDecimal > 0
lcsql = lcsql + [,] + TRANSFORM(lnDecimal)
ENDIF
lcsql = lcsql + [)]
IF lnI = lnFields
lcsql = lcsql +[ ;] + CHR(13) + CHR(10) + [)]
ELSE
lcsql = lcsql + [ ;] + CHR(13) + CHR(10) + [, ]
ENDIF
ENDFOR
RETURN lcsql
ENDFUNC
Following code generates sql create table script for table or cursor in current workspace.
FUNCTION GenerateCreateScript
LPARAMETERS tcCursor
LOCAL ARRAY aa[1]
LOCAL lcAlias, lcCursor, lnFields, lcsql, lcfield, lcType, lnlen, lnDecimal, lnI
lcAlias = ALIAS()
IF EMPTY(lcAlias)
RETURN ''
ENDIF
IF EMPTY(tcCursor) OR VARTYPE(tcCursor) # 'C'
lcCursor = SYS(2015)
ELSE
lcCursor = tcCursor
ENDIF
lnFields = AFIELDS(aa)
lcsql = [ create cursor ] + lcCursor + [ (]
FOR lnI = 1 TO lnFields
lcfield = aa[lni, 1]
lcType = aa[lni, 2]
lnlen = aa[lni, 3]
lnDecimal = aa[lni, 4]
lcsql = lcsql + lcfield + ' ' + lcType + [(] + TRANSFORM(lnlen)
IF lnDecimal > 0
lcsql = lcsql + [,] + TRANSFORM(lnDecimal)
ENDIF
lcsql = lcsql + [)]
IF lnI = lnFields
lcsql = lcsql +[ ;] + CHR(13) + CHR(10) + [)]
ELSE
lcsql = lcsql + [ ;] + CHR(13) + CHR(10) + [, ]
ENDIF
ENDFOR
RETURN lcsql
ENDFUNC
Tuesday, June 24, 2008
Save attachment from Outlook using Foxpro
I need to reprint cards which I receive as Excel file in email. I use the following code to save the attachment in my folders
Local loOutlook, loMapi, loFolder, loInbox, loMailItems, loMail
Local lcBadCardsDir, lcSubject, lnAttachments, loAttach, lcAttachFile, lcSaveFile, lnI
lcBadCardsDir = "c:\badcards\"
Clear
loOutlook = Createobject("outlook.application")
loMapi = loOutlook.GetNamespace("MAPI")
loFolder = loMapi.Folders("Imap.gmail.com")
loInbox =loFolder.Folders("Inbox")
loMailItems = loInbox.Items
For Each loMail In loMailItems
lcSubject = loMail.subject
If 'bad card' $ Lower(lcSubject)
lnAttachments = loMail.Attachments.Count
If lnAttachments > 0
For lnI = 1 To lnAttachments
loAttach = loMail.Attachments.Item[lnI]
lcAttachFile =loAttach.filename
?Justext( lcAttachFile)
If Lower(Justext( lcAttachFile)) = 'xls'
lcSaveFile = lcBadCardsDir + lcAttachFile
loAttach.saveasfile(lcSaveFile )
Endif
Endfor
Endif
Endif
Endfor
loMail = Null
loMailItems = Null
loInbox = Null
loFolder =Null
loMapi = Null
loOutlook = Null
Local loOutlook, loMapi, loFolder, loInbox, loMailItems, loMail
Local lcBadCardsDir, lcSubject, lnAttachments, loAttach, lcAttachFile, lcSaveFile, lnI
lcBadCardsDir = "c:\badcards\"
Clear
loOutlook = Createobject("outlook.application")
loMapi = loOutlook.GetNamespace("MAPI")
loFolder = loMapi.Folders("Imap.gmail.com")
loInbox =loFolder.Folders("Inbox")
loMailItems = loInbox.Items
For Each loMail In loMailItems
lcSubject = loMail.subject
If 'bad card' $ Lower(lcSubject)
lnAttachments = loMail.Attachments.Count
If lnAttachments > 0
For lnI = 1 To lnAttachments
loAttach = loMail.Attachments.Item[lnI]
lcAttachFile =loAttach.filename
?Justext( lcAttachFile)
If Lower(Justext( lcAttachFile)) = 'xls'
lcSaveFile = lcBadCardsDir + lcAttachFile
loAttach.saveasfile(lcSaveFile )
Endif
Endfor
Endif
Endif
Endfor
loMail = Null
loMailItems = Null
loInbox = Null
loFolder =Null
loMapi = Null
loOutlook = Null
Wednesday, June 18, 2008
Building ASP.NET 2.0 Web Sites Using Web Standards
Building ASP.NET 2.0 Web Sites Using Web Standards
http://msdn.microsoft.com/en-us/library/aa479043.aspx
http://msdn.microsoft.com/en-us/library/aa479043.aspx
Labels:
ASP.Net
Subscribe to:
Posts (Atom)