Normal Topic Dynamic Lookups (Read 573 times)
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Dynamic Lookups
Feb 22nd, 2004 at 9:08pm
Print Post Print Post  
I am still doing a lot of experiments with Sesame.  Having a problem with creating a dynamic @XLU command.

The next line is a good line, correct value is returned to HRLYRATE:
Quote:
HRLYRATE = @XLU(@FileName,COMPANY,"frmRates!txtKey","curOnSiteRate")


Trying to duplicate the above command with variables:
Quote:
//1.  Declare variables:
var vgQuote as String
var vgSourceDB as String
var vgKeyElement as String
var vgSourceKeyElement as String
var vgSourceElement as String
var vgLU as String

//2.  Set variable values:
vgQuote = @CHR(34)
vgSourceDB = "@FileName"
vgKeyElement = "COMPANY"
vgSourceKeyElement = "frmRates!txtKey"
vgSourceElement = "curOnSiteRate"


//3.  Set value of vgLU, and confirm with WriteLn:
vgLU = "@XLU("+vgSourceDb+","+vgKeyElement+","+vgQuote+vgSourceKeyElement+vgQuote+","+v
gQuote+vgSourceElement+vgQuote+")"

WriteLn(vgLU)         
//WriteLn value = desired string:
@XLU(@FileName,COMPANY,"frmRates!txtKey","curOnSiteRate")

//4.  Get value by making HRLYRATE equal to variable:
HRLYRATE = vgLU

// or

//5.  Get value by using variables inside @XLU command:
HRLYRATE=@XLU(vgSourceDb,vgKeyElement,"vgSourceKeyElement","vgSourceElement")


The final line in step 4 should be (and is) the same as the original line that is good.  But it does not function as an XLU statement, no value is returned (Type=Money), and no @ERROR message returned.
Conclusion:  It looks like I can replace parameters within the XLU statement, but even though I could normally assign a value to an element by using a variable, I cannot use a variable to reproduce a command.  So forget about step 4 as a method.

The optional final line in step 5 does function as an XLU statement, but generates @ERROR message.  I have also tried using vgSourceDB = @FileName (without the quotes) to get the value vs. using the string @FileName.  And I have tried modifying the @XLU command, both using and eliminating the quotes around the first parameter: "vgSourceDb".  No success.  All four variables do come back with the correct values.

Conclusion:  I have been spending too much time on this and can no longer see the obvious!  Why can't I make an @XLU work with variables in all parameter fields?

Once again, I am not suggesting that this is a bug.  I am just looking to understand what I did wrong, or an explanation of the internal Sesame logic that prevents this process from working.    I suspect it has to do with generating the quotes around the external source references.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Dynamic Lookups
Reply #1 - Feb 23rd, 2004 at 1:42pm
Print Post Print Post  
Well, among other things, you have the same issue as you did in the other thread regarding dynamic GoTo. You are trying to use a string as an element reference.  That is not valid syntax.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Dynamic Lookups
Reply #2 - Feb 23rd, 2004 at 1:42pm
Print Post Print Post  
SBasic is a compiled language. The SBasic source code is run through a process that turns it into a language that the machine can understand but humans cannot. That "machine code" is then what is actually "run". This translation happens well before any SBasic code is actually executed. This is done to produce a much faster program. But it means that there is no dynamic re-interpretation of the SBasic source code during SBasic runtime.

In less complex terms: you can't execute a string variable.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged