Page 5 of 8

Re: How do i call a procedure

Posted: Mon Aug 21, 2017 6:11 pm
by ROBROS
BeGeS wrote: Mon Aug 21, 2017 5:42 pm
ROBROS wrote: Mon Aug 21, 2017 4:23 pm Thank you for the advice, creating a project by IDE and building the .exe will do this for me, right?

Robert
:)

Using IDE is a personal choice.

I'm too heterodox as programmer, so I do not even consider using IDE.

Bernardo
Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked. I tried to use IDE to "write" an app, I simply gave up,

Robert

Re: How do i call a procedure

Posted: Mon Aug 21, 2017 6:52 pm
by Rathinagiri
Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked.
IDE can be perfectly used for the purpose you have mentioned above. This is exactly what I am doing while developing a project. I don't use the Form Designer.

Re: How do i call a procedure

Posted: Mon Aug 21, 2017 8:11 pm
by BeGeS
ROBROS wrote: Mon Aug 21, 2017 6:11 pm Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked. I tried to use IDE to "write" an app, I simply gave up,
At no point has it been my intention to discourage you from using IDE.

I am not the one to judge its advantages or its disadvantages.

Simply that I like to be the lord of my code, in the sense that I will only know it well if I have given birth. Development may be slower, but only at first.

Just one of the first things I've done has been to modify the build.bat file provided by HMG: some small adaptations to leave it to my liking. :mrgreen:

(I "baptized" him as HMGC.bat, the letter C of compiler :roll: :oops: ).

Re: How do i call a procedure

Posted: Mon Aug 21, 2017 8:24 pm
by ROBROS
BeGeS wrote: Mon Aug 21, 2017 8:11 pm
ROBROS wrote: Mon Aug 21, 2017 6:11 pm Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked. I tried to use IDE to "write" an app, I simply gave up,
At no point has it been my intention to discourage you from using IDE.

I am not the one to judge its advantages or its disadvantages.

Simply that I like to be the lord of my code, in the sense that I will only know it well if I have given birth. Development may be slower, but only at first.

Just one of the first things I've done has been to modify the build.bat file provided by HMG: some small adaptations to leave it to my liking. :mrgreen:

(I "baptized" him as HMGC.bat, the letter C of compiler :roll: :oops: ).
Bernardo, you have not discouraged me to use IDE, maybe I'm just too "simple minded" to use it, and though I am not using it, it is very helpful to have a look at it in the samples, and so thanks to Roberto Lopez for giving us such a tool.

Robert

Re: How do i call a procedure

Posted: Mon Aug 21, 2017 9:51 pm
by BeGeS
ROBROS wrote: Mon Aug 21, 2017 8:24 pm Bernardo, you have not discouraged me to use IDE, maybe I'm just too "simple minded" to use it, and though I am not using it, it is very helpful to have a look at it in the samples, and so thanks to Roberto Lopez for giving us such a tool.
Completely agree with you.
For those of us who are learning, everything is very useful and everything can be taken advantage of.
And my thanks to Roberto López and my admiration for his work are enormous.

IDE or no IDE is like choosing between beach or mountain for vacation. I am from the beach, and if more crowded, better, but I know people who would not go even if they charged money. They prefer to rest in an isolated environment. Very good. :D

Re: How do i call a procedure

Posted: Mon Sep 04, 2017 6:53 pm
by ROBROS
Hello friends,

I was so glad to have back "my append from sdf". It works, but I have to save "sheet.xls" to "sheet.prn" and so on. Then I remembered that in my self-introduction Marek and Serge told me I could directly read from excel and write to dbf.

Serge sent this function:

Function ImportData
LOCAL oExcel, oWorksheet, i

IF ! MsgYesNo('Start to process?','Confirm')
return
endif

oExcel := CreateObject( "Excel.Application")
oExcel:Workbooks:Open( GetCurrentFolder()+"\newshop.xls" ) // here right name
oExcel:Visible := .t.
sele a
use shoptype
zap

for i = 4 to 7 // here
cTypeO=oExcel:WorkSheets(1):cells(i,2):value
cTypeN=oExcel:WorkSheets(1):cells(i,3):value
cCustCode=left(oExcel:WorkSheets(1):cells(i,4):value,6)
cCustName=subs(oExcel:WorkSheets(1):cells(i,4):value,8,50)
appe blank
repl typeo with cTypeO, typen with cTypeN, cust_code with cCustCode, cust_name with cCustName
next
close databases
Return


There is one problem I could not solve:

If "counter" i=NumberOfLastRow+1 then, though the records are appended to dbf-file, the program crashes at runtime.

Of course I could open excel-file outside the program press ctrl and end and could enter the NumberOfLastRow via textbox-control Seems not very professional.

In a german xbase-forum I found these 3 lines of code:

oExcel:Cells:Item(65536, nColumn).Select()
oExcel:Selection:End(xlUp):Select()
nLastRow:= oExcel:ActiveCell:Row()

and added them to Serge's function.

Compiling the first of these 3 lines I get a syntax-error.

I have no knowledge of VBA.

Who knows what went wrong?

Robert

EDIT: Maybe the crash can be avoided by errorhandling?

Re: How do i call a procedure

Posted: Mon Sep 04, 2017 9:06 pm
by mol
Maybe your excel sheet contains data other type than Character?

Try this change of reading cells:

Code: Select all

cTypeO=oExcel:WorkSheets(1):cells(i,2):Text
cTypeN=oExcel:WorkSheets(1):cells(i,3):Text
cCustCode=left(oExcel:WorkSheets(1):cells(i,4):Text,6)
cCustName=subs(oExcel:WorkSheets(1):cells(i,4):Text,8,50)

Re: How do i call a procedure

Posted: Mon Sep 04, 2017 9:43 pm
by ROBROS
Marek,

as I wrote, data are appended, so data type should not be the problem, (but when i >number of last row of excel sheet, I get a runtime error). but I will try your suggestion tomorrow at office. On my pc at home (Linux) no excel is available.

Thank you
Robert

Re: How do i call a procedure

Posted: Tue Sep 05, 2017 4:54 am
by KDJ
ROBROS wrote: Mon Sep 04, 2017 6:53 pm ...
oExcel:Selection:End(xlUp):Select()
...
What is the value of xlUp ?

Re: How do i call a procedure

Posted: Tue Sep 05, 2017 6:24 am
by ROBROS
KDJ wrote: Tue Sep 05, 2017 4:54 am
ROBROS wrote: Mon Sep 04, 2017 6:53 pm ...
oExcel:Selection:End(xlUp):Select()
...
What is the value of xlUp ?
I don't know, I just typed in the lines. As I wrote I have no knowledge of VBA.

Robert