Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
2 Report Questions
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00106460
Message ID:
00106758
Views:
32
I just want to state that I feel Ed's suggestion was a good one. I think it was enough to put Tom on the right track. I don't think answers need to include ideas about where to put error checking, parameter checking, files existence checking, etc..

We can make the assumption that the person posting the question will take the suggestion and use his/her programming techniques and practices to implement the idea...

Just my opinion...

Joe


>>If I'm printing a report of buildings, how do I print the agent's name >corresponding to each building. It seems as though I'll need to do a SELECT SQL statement somewhere.
>
>There are several approaches to solving this problem:
>
>1. You can do a SQL-Select that joins the two tables - yielding 1 cursor with both the building info and the agent's name for that building. This would be
>my approach.
>
>2. You could set a relation between the two tables so that when the record pointer moves in the building table, the record pointer in the agents table will move as well.
>
>Let me know how things work...
>
>Oh yes, with regard to your first issue, it appears that Ed has given you something that will work. However, I have one suggestion for improving the quality a bit. Here is the function in question:
>
><<
>Function getpictureIf
> mytable.field1=1
> return c:\file1.bmp
>else
> return c:\file2.bmp
>endif
><<
>
>There are several potential problems here. First, an assumption is made that an alias called mytable exists. Further, it assumes that a field called field1 exists. Moreover, it assumes the data type of field1 is numeric. Finally, it is hardcoded. When ever you need to change a bitmap or something else, you will need to change code and re-compile.
>
>Might I suggest an alternative to Ed's approach???
>
>1. Create a table called bitmaps with the following structure:
>
>Id, Integer
>File, C,50
>
>2. Create an index on both ID and File.
>
>3. Create a function called GetBitMap:
>
>Function GetBitMap(ID)
> Local cRetVal
> cRetVal = Space(0)
> */ Do parameter checking here
> */ Set an inline error trap if necessary
> If !Used("bitmaps")
> Use bitmaps In 0 Shared Again
> Endif
> If Seek(id,"bitmaps","id")
> cRetVal = bitmaps.file
> Else
> */ You will need to specify a default bitmap file here.
> */ otherwise, you will get an error.
> cretval = "c:\mydefault.bmp"
> Endif
> */ Reset other environmental settings if necessary
> */ Reset Error Trap if necessary
> Return cRetVal
>EndFunc
>
>4. Then, in the report, you can modify your call like this:
>
>GetBitMap(table.field)
>
>The idea here is that you should never have to recompile code if a change in data occurs. Heck, that's what Cobol developers have to contend with<s>.
>
>Alternatively, you could do a sql select that joins the bitmap and building or agent files or you could do a set relation - obviating the need to do a function
>in the first place. After all, you are returning a text string pointing to a file.
>
>Just another idea.....
Joseph C. Kempel
Systems Analyst/Programmer
JNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform