Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Question about linking?

Author
Message
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 1st Jul 2006 23:05
Can anyone help explain how to do this or point me to any tutorials?

I think I need to link to another file to do what I want (Would this be a DLL?)

Let me explain! Basically I want a file that stores information about a large number of objects (eg 1,000) that will be accessed by the main program. It would be a bit like a bus timetable whereby for each object number there would be the object type, object name, the time to appear on screen and other info..

Then, the main program would check the file every second (I am using a real time clock to do this) and select the next object in the list as dictated by the timetable.
eg at 10 seconds it loads object 1 and does stuff, at 12 seconds it loads object 2 and does stuff, etc...

I am completely clueless about linking!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 1st Jul 2006 23:50 Edited at: 1st Jul 2006 23:50
I'll do this with a string, which is the easiest way. You can put loads of numbers on each line to represent different things, and split it up into variables.

Here we go:


Copy this clip into a new project and save it as temp.dba

Then put the following into a txt file called data.txt and save it in the same directory as temp.dba. Run and enjoy!

05,First line
10,Five seconds later, the second line
05,twenty seconds later, the thirdline
9999

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 2nd Jul 2006 11:27
Great stuff, Thanks a million!
Won't get to try this until later now, so might need to come back and ask you bits again!!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 2nd Jul 2006 11:39
Feel free!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 3rd Jul 2006 21:56
Ok, I have tried this and looked up the new commands I have never used. I am kind of understanding how it works, but I don't quite understand (in the text file) why you need the 05, the 10 and the 05 at the beginning of each line?
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 3rd Jul 2006 22:21
Forget that last post, I got it now!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 3rd Jul 2006 22:31
Oops, yeah, would have been more obvious if I hadn't made a mistake in the text!

05,First line
10,Five seconds later, the second line
05,twenty seconds later, the thirdline
9999

Should have been
05,First line (with a 5s pause)
10,Five seconds later, the second line (with a 10s pause)
05,Ten seconds later, the third line (with a 5s pause 'til the end)
9999

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 3rd Jul 2006 22:40
Yes I got it now. This is ok for printing the letters in a string but what about using the info in the txt file to use in commands eg to load different objects or use in a variable.

Lets say I have two different object files:
"H-ObjectA.3DS" and H-ObjectB.3DS

After 5 seconds I want to load Object A and position at 0,0,0
After 10 seconds I want to load Object B and position at 5,5,0

The information to tell the program which object to load is contained in the txt data file. How would I rewrite the function to obtain the data and in what format would i store the data in the txt file?
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 5th Jul 2006 20:36
Seeing as tho 'Dream and Death' is the only person who seems to help me on this forum, I was wondering if you are there 'DAD' and could help me with this, as I was hoping to continue this thread with some further questions. Your help is greatly appreciated!!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 5th Jul 2006 23:21
Don't worry Forest I'm here!

Start with how you want to put things in the text file, and work from there.

You say after 5 secs, you want to show ObjectA at 0,0,0
This suggests that we cheat and code the five second delay in then we can have a first line like:
10,ObjectA,0,0,0
which then contains the pause before the second line
99,ObjectB,5,5,0
for the second object. 99 as an arbitrary pause
Then and end of file indicator
9999

Our code would look somewhat like this:


Note - this is untested, and may require debugging, but I think it should work!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 6th Jul 2006 20:07
Woah! Think I'll have to give that some study time! That is totally brilliant and looks well on the way to what I want to achieve in my project, A thousand Thankyou's!

Would you mind if I emailed you any questions direct as I see the road ahead getting a bit bumpy with what I want to do!!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 6th Jul 2006 21:57
Feel free Forest! I love doing stuff like this - I think string manipulation and stuff is kinda my area!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 6th Jul 2006 22:25
I will then, great stuff! Might have to take a break for couple of days now tho, it is just too damn hot here to concentrate!!
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 12th Jul 2006 21:34
Hey Dream & Death, did you get my email?

I was just following up from the code you helped me with above.
The compiler says that for: dim Next read as string etc.. the arrays should include brackets, so should this be re written as
dim() Next read as string or should these be GLOBAL variables?

Also it is saying the array should include brackets in the function Instr. the line of code that states: inc tmp_matched, 1
is the line which throws up this message. But this isnt an array is it??
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 12th Jul 2006 21:59 Edited at: 12th Jul 2006 22:01
Sorry Forest - haven't checked my e-mail for a day or two!

I typed the last code snippet while doing a VBA program in the background, in VBA you DIM any variable, not just arrays.

I'll just correct it...


"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 12th Jul 2006 22:12
No problem, thanks, I'll try that!
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 17th Jul 2006 22:26
Ok, finally got round to this again, now have another error in the main code, it is at the line saying:

CurrentObj=left$(DataRead,Instr(DataRead,",",1)-1)

Error says:

Cannot perform 'Integer' cast on type 'TEMP7'

Also should the variables at top of code be defined GLOBAL?
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 17th Jul 2006 22:30
is CurrentObj supposed to be a string? Guessing from the name I guess not. In that case you might want to have val surrounding what it equals like this-
CurrentObj=val(left$(DataRead,Instr(DataRead,",",1)-1))

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 18th Jul 2006 14:25
No Daemon, - second line of the code should give you a hint - "CurrentObj as string"! It's the name of the CurrentObj - in this case this little example only ever uses object number 1.

Forest, I'm sorry that the snippet isn't working - sometimes DBP has problems when casting values from one type to another when called as a parameter of a function:
i.e.
Print str$(1*10) sometimes fails,
whereas
x as integer
x=1*10
Print str$(10) is less likely to fail - it is weird and annoying.

The clip as is does compile and run on my machine, but I've tried something in the clip below that may get round it for you.

I hope this helps!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 18th Jul 2006 23:17
No, still getting same error except it says 'TEMP3' this time.
If you have no other ideas, I may have to email the whole code to let you try? What you think?
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 19th Jul 2006 16:46
Yeah, send it and I'll take a look.

There are a few other tricks (such as copying the code to textpad, deleting the project and starting again!)

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 19th Jul 2006 21:32
Ok it's there, thanks!
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 24th Jul 2006 19:50
Hey there "DAD"!

Have you had any luck with that code I sent, or did you not get it?
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 25th Jul 2006 15:06
Sorry Forest - been away on holiday for a few days.

DBP is being real weird with this code.

If you assign string variables with $ and floats with #, it works - it just doesn't like the "as string" for some reason.

I'll update the code this evening for you.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 25th Jul 2006 22:35
Thanks very much! I look forward to seeing what you have done and will have to remember that in future.
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 27th Jul 2006 23:03 Edited at: 27th Jul 2006 23:04
i know you may have been busy or forgotten to update this code, but no worries!
I have had a go myself as you described and have managed to get the program to compile but I am now getting a runtime error saying, "Only Positive numbers allowed at line..."

The problem line (changed as described) is:

NextRead=Timer()+val(left$(DataRead$,Instr(DataRead$,",",1)-1))*1000
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 28th Jul 2006 11:16
Forest,

I have (finally) got round to modifying the code to avoid the casting errors. The error you are looking at (pos number) occurs if you pass a negative number to Left$, e.g. Left$(Name$,-2)

If you can, step through the program, or print out, what Instr(DataRead$,",",1)-1 is giving at this point. It may be a fault with my code, but it may be a fault with your text file!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 2nd Aug 2006 21:16
Hi there DAD! I am still struggling with this code. To be honest I dont fully understand the main part of the code. I have looked up the commands and get their meanings but for instance, I dont understand what Instr is meaning?

Would it be possible to write some more detailed comments for each line to explain what each line is doing.

I should then be able to find what is going wrong.
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 3rd Aug 2006 14:19
Yeah, give me a little while and I will sort you something out. I t may be a day or two, for personal reasons!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Forest
18
Years of Service
User Offline
Joined: 29th May 2006
Location:
Posted: 3rd Aug 2006 21:40
Thanks a million, You are a diamond!

Login to post a reply

Server time is: 2024-09-25 05:22:57
Your offset time is: 2024-09-25 05:22:57