variable of variables

Say I have 2 scenarios and I want to use a different
variable depending on which scenario applies without coding
this logic.

So I could have a database table t_variables which has:

Scenario:  Variable:
---------  --------
1          v_name
2          v_company

In my Powerbuilder code I'd have values in v_name &
v_company.

What I'd like to be able to do is to select which variable
to use from the table and assign that to something, e.g.

select variable
into v_variable
from t_variables
where scenario = 1

so at this point v_variable would be 'v_name'

I'd then like to be able to assign whichever variable was
selected to something e.g.
dw.title = v_name \\whatever is in v_variable

I'm sure it can be done, I'm hoping that someone can point
me in the right direction.

Thanks and Regards,
Sean
0
Sean
3/31/2010 10:49:23 AM
sybase.powerscript 7704 articles. 0 followers. Follow

2 Replies
1109 Views

Similar Articles

[PageSpeed] 57

You're sure it can be done? It can?

The first thought that came to my mind was to use a hashtable instead of 
variables. PowerBuilder doesn't have a native hashtable, but a datastore 
would work just as easily... probably better than rolling your own.



On 3/31/2010 5:49 AM, Sean Dwyer wrote:
> Say I have 2 scenarios and I want to use a different
> variable depending on which scenario applies without coding
> this logic.
>
> So I could have a database table t_variables which has:
>
> Scenario:  Variable:
> ---------  --------
> 1          v_name
> 2          v_company
>
> In my Powerbuilder code I'd have values in v_name&
> v_company.
>
> What I'd like to be able to do is to select which variable
> to use from the table and assign that to something, e.g.
>
> select variable
> into v_variable
> from t_variables
> where scenario = 1
>
> so at this point v_variable would be 'v_name'
>
> I'd then like to be able to assign whichever variable was
> selected to something e.g.
> dw.title = v_name \\whatever is in v_variable
>
> I'm sure it can be done, I'm hoping that someone can point
> me in the right direction.
>
> Thanks and Regards,
> Sean
0
Jason
3/31/2010 2:17:05 PM
PowerScript does not support indirection, and it is compiled, not 
interpreted, so you can't make it generate and execute code on the fly. 
There's going to be a big ugly CHOOSE CASE or nested IF ELSEIF involved.
And don't forget to deal with the possbility that the variable name returned 
from the table doesn't exist.

This would be very simple if rather than variables, the values of interest 
were columns retrieved from a table. But the handy DW expression functions 
IF and CASE have not made it into PowerScript, and the DW engine is 
encapsulated and knows nothing about PowerScript variables other than the 
values it gets as arguments to its methods.

-- 
Report Bugs to Sybase:  http://case-express.sybase.com/cx/welcome.do
Product Enhancement Requests: 
http://my.isug.com/cgi-bin/1/c/submit_enhancement


"Jason 'Bug' Fenter [TeamSybase]" <jason.fenter@teamsybase.com> wrote in 
message news:4bb35961$1@forums-1-dub...
> You're sure it can be done? It can?
>
> The first thought that came to my mind was to use a hashtable instead of 
> variables. PowerBuilder doesn't have a native hashtable, but a datastore 
> would work just as easily... probably better than rolling your own.
>
>
>
> On 3/31/2010 5:49 AM, Sean Dwyer wrote:
>> Say I have 2 scenarios and I want to use a different
>> variable depending on which scenario applies without coding
>> this logic.
>>
>> So I could have a database table t_variables which has:
>>
>> Scenario:  Variable:
>> ---------  --------
>> 1          v_name
>> 2          v_company
>>
>> In my Powerbuilder code I'd have values in v_name&
>> v_company.
>>
>> What I'd like to be able to do is to select which variable
>> to use from the table and assign that to something, e.g.
>>
>> select variable
>> into v_variable
>> from t_variables
>> where scenario = 1
>>
>> so at this point v_variable would be 'v_name'
>>
>> I'd then like to be able to assign whichever variable was
>> selected to something e.g.
>> dw.title = v_name \\whatever is in v_variable
>>
>> I'm sure it can be done, I'm hoping that someone can point
>> me in the right direction.
>>
>> Thanks and Regards,
>> Sean 


0
Jerry
3/31/2010 7:43:50 PM
Reply:

Similar Artilces:

variable variables?
Hello! How to make a variable receive an increment in the name? I want to do it for example: I have: Label1->Caption = "1"; Label2->Caption = "2"; Label3->Caption = "3"; Label4->Caption = "4"; And I want to do something like that: for (i=1; i<5; i++) { Label+i->Caption = i; } Any idea? Can I do something like that? Thanks and regards Alexandre Create a vector of pointers to the various objects. In your case below, construct a vector (called Labels) of pointers to TLable long enough to hold pointers to...

variable not a variable
Error:Must declare the variable '@cartDateTime'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Must declare the variable '@cartDateTime'. Dim connStr As SqlConnection            Dim cmdInsert As SqlCommand            Dim strInsert As String      &n...

Variable Variables
Hi, Maybe the solution is very simple, but how do I create variable variables in vb.net? I want to use the value of a variable as a part of the name of another variable. A very simple example below: code: Dim a As String a = "1" Label a.Text = "hi" page: <asp:Label id="Label1" runat="server">Label</asp:Label> In need this to change a range of values by using just one loop. I can´t do that without creating a variable variable name. Hi, check out this little demo application I created for you: ...

my $variable verse $variable
Greetings, Being new to perl can someone explain why my is in form of variables and what is the purpose? Thanks TMC wrote: > Greetings, > Being new to perl can someone explain why my is in form of variables > and what is the purpose? 'my' is used to declare a variable and limit its scope. If you `use strict;` (and you should) you must declare all unqualified variables. #!/usr/bin/perl use strict; use warnings; my $a = 'a'; { my $a = 'b'; print "$a\n"; } print "$a\n"; __END__ See: perldoc -f m...

Variable within a variable?
I have a lot of text boxes that I need to get into an array.  Say they are called txt1 - txt80.  Is it possible to use an index variable to go through each text box?  Something like this txt"index" <---obviously not correct, but is there something out there like this?Thank you for any help You can iterate through your page controls and put them into the array if they are of type TextBox.. foreach(Control wc in Page.Form.Controls) { if (wc.GetType().Name == "TextBox") { //add the control to the array } }Kumar Reddi Works well, thanks for your help!...

Variable variable names
------_=_NextPart_001_01CB7729.624A48CF Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, In the below code I am desperately trying to accomplish the valid use of = variable variable names but still fail. I have already read many sites, = tutorials, mailing list posts, all saying that this is best accomplished = by using a hash. Please would you tell me if I understood that correctly = and, even more important, if I interpreted and tried to realize it = correctly? And if someone could tell me why the script gives me error...

Assigning a Variable with other Variables.
I have a real quick noob question. I have the following variables. First_Name = Server.HtmlEncode(txtFirstName.Text) Last_Name = Server.HTMLEncode(txtLastName.Text) I want to assign these two variables to another along with some other information so it looks like tte/john.doe I have this, but I am obvisouly doing it wrong. Thanks for any help. UserID = "tte/"First_Name"."Last_Name Let me guess: you came from PHP. Try UserID = string.Format("tte/{0}.{1}", First_Name, Last_Name) or UserID = "tte/" &am...

centralized variable variables
Hi, Hi, I want to set pathnames in a centralised module (called with use or require). Is it possible to send an variable (through the env or as an argument, or ....) so I can use the variable $dir from the module test.pl to set the variable $vardir in param.pl. ?? Any help greatly appreciated. Bernard -----------cat test.pl #!/usr/bin/perl #use strict; my $dir = $ARGV[0]; require "param.pl"; print("path1 $path1\n"); print("path2 $path2\n"); # ---------cat param.pl #!/usr/bin/perl my $basepath = "/var/tmp"; my $vardir =...

variable variable-names
Hi all, I'm trying to write a script that will pull out values for form data radio buttons for muliple answers. This is what a standard line looks like: <INPUT TYPE="radio" NAME="answer1" VALUE="blah">Blah For each question I've tried to make up a separate set of arrays containing the button values: open (QUES, "<questions.poll"); foreach $line (<QUES>) { chomp $line; if ($line =~ m|[^"]*NAME="answer(\d)"\s*VALUE="([^"]*)"|) { $num = $1; $value_label = $2; ...

been a while
I haven't coded in perl for far too long... that aside.. How do I define variable variable names ? I have an array that contains the header cells of some long columns, from which i want to create new arrays which are called by the names in the array. e.g. @header = (Name, Address, Date, Expiry) And create arrays @name, @address...etc Header contents, of course, change order and content. Hope you can help Michael Carmody MDU, Public Health Lab Dept. of Microbiology and Immunology The University of Melbourne, Parkville On Thursday, May 23, 2002, at 05:39 , ...

Global variables / special variables / variable identifier with just one character
Expected error message: "Global symbol "$b" requires explicit package name". However, I get result: "test". I've checked the special variables and it looks like $b is one of these. use warnings; use strict; zzz ($b); print "$b\n"; sub zzz{ $_[0] = "test"; } Does it mean - that in general - we should not use one character variables in Perl? thanks adam ------=_NextPart_000_0011_01C4ADBA.05A29580 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable "Adam" &l...

Create variable, set variable, delete record, drop variable during replication
This is a multi-part message in MIME format. ------=_NextPart_000_0008_01C56C1A.126DC360 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Not sure if this is anything that we can control by changing a setting, = but seems to add extra message traffic during our replication process ( = dbremote ). We have Verify_all_columns set to ON=20 ASA version 9.0.1.1964 I. 05/05 10:52:38. DELETE FROM DBA.SmartPad WHERE SmartPadNo=3D1180877975 I. 05/05 10:52:38. CREATE VARIABLE n12 LONG VARCHAR I. 05/05 10:52:38. SET n12 =3D '...

Variable name in database or other variable
Hi at all, I need to use, in powerbuilder script, a variable name that's stored in another variable! Example: string ls_name = "Valter" string ls_varname = "ls_name" MessageBox("My name is",ls_varname) I need to show in the message box "My name is"+"Valter" Any help will be very appreciated! Thanks and regards, Valter Cavallino You quoted ls_name in the second line of code. It should be unquoted to assign the value of variable ls_name to ls_varname. -- Chris Keating Sybase Adapt...

Bind variables in a variable list
------_=_NextPart_000_01C0A8F1.FF033980 Content-Type: text/plain; charset="iso-8859-1" I have to create an SQL statement of the form select * from table where attr1 in ( 1,2,3.....n) and attr2 in ( 'ABC', 'DEF', ....., 'asdf'); where the number of entries within the variable lists is driven by the user interface. As a result the number of elements within the lists can go from one to many. I would like to use bind variables to represent the variables lists. I tried one method where .. $sql="select * from table where attr1 in ( ? ) an...

Web resources about - variable of variables - sybase.powerscript

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

Mozilla moves Firefox to variable release schedule
... schedule process "carefully" and learning "a lot" from it in the past years, Mozilla has announced that Firefox is now moving to a variable ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Staley: 'A lot of different variables...been a hard year'
... 41° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Staley: 'A lot of different variables...been ...

Resources last updated: 2/12/2016 10:17:46 PM