logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
masterdata  
#1 Posted : Monday, April 26, 2010 3:10:25 PM(UTC)
masterdata

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/26/2005(UTC)
Posts: 49
Location: Big Bear Lake, CA

I have been reading through the forum posts to see if this has been answered before. The concept is mentioned a lot, but I can't find an answer. Can you provide example code for sending a function value to a .dll (Powerbasic). Please include both the MetaStock indicator that would send the value (the external function formula) and the .dll code that will read (receive) the value. For example, for simplicity's sake, lets take a 4 day simple moving average calculated in a standard MetaStock function formula and send (and use) that value in the .dll. Thank you. LPC
wabbit  
#2 Posted : Monday, April 26, 2010 6:27:33 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)

There are examples of how to pass information to the MSX functions in the MDK manual and in the sample codes in the install directory. Have a look in the manual/code/forum for the a_psFuncArgDef structure, in particular a_psFuncArgDef->iArgType

wabbit [:D]

masterdata  
#3 Posted : Monday, April 26, 2010 6:44:57 PM(UTC)
masterdata

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/26/2005(UTC)
Posts: 49
Location: Big Bear Lake, CA

Hi Wabbit, Yes, the manual was my first choice, but I cannot find the thing. Its on on one of my computers somewhere, but is not in the install folder where I keep the installation files. I did a full search, emailed msdevkit@equis.com with no luck. I purchased MDK well over five years ago. I remember I had to ask for it separately even at that time. Can you send me one separately? (lc@masterdata.com) Thank you. Larry Carhartt
wabbit  
#4 Posted : Monday, April 26, 2010 9:09:24 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
masterdata  
#5 Posted : Monday, April 26, 2010 9:56:12 PM(UTC)
masterdata

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/26/2005(UTC)
Posts: 49
Location: Big Bear Lake, CA

Thank you, Wabbit. I can now work tonight instead of worrying about it.
masterdata  
#6 Posted : Tuesday, April 27, 2010 8:22:27 PM(UTC)
masterdata

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/26/2005(UTC)
Posts: 49
Location: Big Bear Lake, CA

Hi Wabbit,

Well, I guess I will build my own pseudo manual. Actually, the biggest obstacle in writing a MS plug-in (in my opinion) is understanding the variables. I understand where the variable names came from in the sample dll code, but I can't remember from one variable to the next what they mean. So that is my starting point. Understanding the variables. Here is my interpretation for the Power Basic version: Power Basic Variables a_psDataRec MS price data sOpen Base symbol open price @a_psDataRec.sOpen sHigh Base symbol high price @a_psDataRec.sHigh sLow Base symbol low price @a_psDataRec.sLow sClose Base symbol close price @a_psDataRec.sClose sVol Base symbol trade volume @a_psDataRec.sVol sInd Base symbol open interest @a_psDataRec.sInd iFirstValid First record in data array @a_psDataRec.sClose.iFirstValid iLastValid Last record in data array @a_psDataRec.sClose.iLastValid @pszSymbol Base symbol of MS function @a_psDataRec.@pszSymbol iPeriod Data period of base symbol DataPeriod = CHR$(@a_psDataRec.iPeriod) a_psDataInfoArgs MSXDataArray Data Arrays Series of values like for a moving average a_psNumericArgs MSXNumeric Numeric arguments Fixed value like a moving average divisor or any static single value a_psStringArgs MSXString String arguments String passed from MS to the dll a_psCustomArgs MSXCustom Custom arguments Any value passed from MS defined for use in the dll a_psResultRec Results to be returned to MS....One value I am sure this is second nature to the gurus among you, but I only get to visit this code on occasion so its akin to starting over again. If you see anything wrong, I would appreciate a correction. Once you get what the variables mean, the rest is more or less straight-forward (I hope). I will now write my plug-in.

Thank you.
wabbit  
#7 Posted : Tuesday, April 27, 2010 8:27:32 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
If you read the header files where the data structures are defined, you will get a better appreciation of what is going on in the background of the MSX functions.


wabbit [:D]

masterdata  
#8 Posted : Tuesday, April 27, 2010 8:41:47 PM(UTC)
masterdata

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/26/2005(UTC)
Posts: 49
Location: Big Bear Lake, CA

Honestly, I think I understand the functions. Its the variable names that are used that is so confusing to me and I think to most. The functions are pretty straight-forward. Anyway, we'll see. Thank you for your guidance.
masterdata  
#9 Posted : Wednesday, April 28, 2010 4:04:52 PM(UTC)
masterdata

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/26/2005(UTC)
Posts: 49
Location: Big Bear Lake, CA

I have everything working but one of the arguments I am using is an MSXString. It is available to the dll in the variable @a_psStringArgs.pszStrings(0). The value is apparently present and the plug-in works without error. The numerical values using both a MSXDataArray and MSXNumeric are passed just fine. By the way, the MSXDataArray answered my original question about sending a function value to the dll. Perfect. So far though I cannot translate the @a_psStringArgs.pszStrings(0) into the actual word. The word I am trying to pass from MetaStock is "Test" and I get varying translations like "x" or "_" or "@". Can you suggest what I am obviously doing wrong? Thank you.
masterdata  
#10 Posted : Wednesday, April 28, 2010 5:08:43 PM(UTC)
masterdata

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/26/2005(UTC)
Posts: 49
Location: Big Bear Lake, CA

I found my answer.To actually translate the value to text you need to assign the value of the dll variable to the variable of the following type: LOCAL Example AS MSXDataInfoRec PTR And then to actually translate to the original text: Example = @a_psStringArgs.pszStrings(0) and then Your original text = @Example Life is good. Everything works. Thank you, Wabbit.
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.