Tricky
I'm trying to do the following
string sString = "Here is a test string";
string sFieldRef = "sString";
MessageBox.Show (sFieldRef); //How do I get this line to display: Here is a
test string instead of just sString???
// I am trying to access the
value of sString via sFieldRef
I want the messagebox to show what's stored
in sString (Here is a test string) but by
only using sFieldRef.
I know in Clipper, this is referred to as Macro Expansion.
Not sure how to do this in c#
Thanks in Advance,
Chris 5 1299
Hi,
seems like you need something like a string table, right ?
Just use a Hashtable (or a more memory efficient mapping) to store the
relation between the reference string and the target string.
You do have the query the hashtable everytime to get the target string. No
pain, no gain, of course.
You should also consider using constant integers as the reference. Much
more time and space efficient.
Greetings,
Bram.
"name" <na**@place.com > wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl... Tricky
I'm trying to do the following
string sString = "Here is a test string"; string sFieldRef = "sString"; MessageBox.Show (sFieldRef); //How do I get this line to display: Here is
a test string instead of just sString??? // I am trying to access
the value of sString via sFieldRef
I want the messagebox to show what's stored in sString (Here is a test string) but by only using sFieldRef.
I know in Clipper, this is referred to as Macro Expansion. Not sure how to do this in c#
Thanks in Advance,
Chris
"name" <na**@place.com > wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl... Tricky
I'm trying to do the following
string sString = "Here is a test string"; string sFieldRef = "sString";
Uh, how about just assign the sString variable to the sFieldRef variable?
Like:
string sFieldRef = sString;
by using the quotes, you are just assigning a string, "sString", rather than
the value that is stored there.
MessageBox.Show (sFieldRef); //How do I get this line to display: Here is
a test string instead of just sString??? // I am trying to access
the value of sString via sFieldRef
I want the messagebox to show what's stored in sString (Here is a test string) but by only using sFieldRef.
I know in Clipper, this is referred to as Macro Expansion. Not sure how to do this in c#
Thanks in Advance,
Chris
I can't do that because I will be reading from a file the names of fields
ie:
say in my program I have a class that has three variables:
sName,sAddress, sPhoneNumber
I will have a class function that will created a formatted string based on
the order specified by
a text file.
for example, if my program reads from a file that looks like:
file.txt
------------
sAddress
sName
sPhoneNumber
then when I call my output class function, it should display something like
123 First Avenue
Bob Jones
(555) 666-7777
if I change file.txt to look like this:
file.txt
------------
sPhoneNumber
sAddress
sName
then my class output function will display
(555) 666-7777
123 First Avenue
Bob Jones
Thanks,
Chris
"Gary Morris" <gm*******@caro lina.rr.com> wrote in message
news:u8******** ******@TK2MSFTN GP10.phx.gbl... "name" <na**@place.com > wrote in message news:uu******** ******@TK2MSFTN GP12.phx.gbl... Tricky
I'm trying to do the following
string sString = "Here is a test string"; string sFieldRef = "sString"; Uh, how about just assign the sString variable to the sFieldRef variable? Like:
string sFieldRef = sString;
by using the quotes, you are just assigning a string, "sString", rather
than the value that is stored there.
MessageBox.Show (sFieldRef); //How do I get this line to display: Here
is a test string instead of just sString??? // I am trying to access the value of sString via sFieldRef
I want the messagebox to show what's stored in sString (Here is a test string) but by only using sFieldRef.
I know in Clipper, this is referred to as Macro Expansion. Not sure how to do this in c#
Thanks in Advance,
Chris
I would recommend the Hashtable approach specified by Bram first off. However,
you can use reflection to achieve the same goal. If the field is sAddress you
can
use Type.InvokeMemb er() with the appropriate overloads to get the value.
You can't do macro expansion, because this is macro expansion at run-time, not
macro expansion in the generic sense that is normally done as a precompilation
step.
--
Justin Rogers
DigiTec Web Consultants, LLC.
"name" <na**@place.com > wrote in message
news:PP******** ************@tw ister.tampabay. rr.com... I can't do that because I will be reading from a file the names of fields ie:
say in my program I have a class that has three variables: sName,sAddress, sPhoneNumber
I will have a class function that will created a formatted string based on the order specified by a text file.
for example, if my program reads from a file that looks like:
file.txt ------------ sAddress sName sPhoneNumber then when I call my output class function, it should display something like 123 First Avenue Bob Jones (555) 666-7777
if I change file.txt to look like this:
file.txt ------------ sPhoneNumber sAddress sName
then my class output function will display (555) 666-7777 123 First Avenue Bob Jones Thanks,
Chris
"Gary Morris" <gm*******@caro lina.rr.com> wrote in message news:u8******** ******@TK2MSFTN GP10.phx.gbl... "name" <na**@place.com > wrote in message news:uu******** ******@TK2MSFTN GP12.phx.gbl... Tricky
I'm trying to do the following
string sString = "Here is a test string"; string sFieldRef = "sString";
Uh, how about just assign the sString variable to the sFieldRef variable? Like:
string sFieldRef = sString;
by using the quotes, you are just assigning a string, "sString", rather than the value that is stored there.
MessageBox.Show (sFieldRef); //How do I get this line to display: Here is a test string instead of just sString??? // I am trying to access the value of sString via sFieldRef
I want the messagebox to show what's stored in sString (Here is a test string) but by only using sFieldRef.
I know in Clipper, this is referred to as Macro Expansion. Not sure how to do this in c#
Thanks in Advance,
Chris
Ah, that makes more sense. I was looking at the code and
it just seemed unusual that the field name was in quotes.
That would have just assigned the string in quotes to that
variable, but I see now how this is supposed to work. Good
suggestion.
"Justin Rogers" <Ju****@games4d otnet.com> wrote in message
news:O6******** ******@tk2msftn gp13.phx.gbl... I would recommend the Hashtable approach specified by Bram first off.
However, you can use reflection to achieve the same goal. If the field is sAddress
you can use Type.InvokeMemb er() with the appropriate overloads to get the value.
You can't do macro expansion, because this is macro expansion at run-time,
not macro expansion in the generic sense that is normally done as a
precompilation step.
-- Justin Rogers DigiTec Web Consultants, LLC. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: xcomm |
last post by:
Hi All,
<?php
$vars= array("_SERVER","_SERVER","_SERVER","_SERVER","_SERVER","_SERVER");
foreach($vars as $var) {
if(isset($$var))echo("$var: ${$var}<br>\n");
}
?>
php.net:
|
by: Robert Mark Bram |
last post by:
Hi All!
Is there a way to reference a window by name without doing something like
this:
open (, 'windowName');
The open method will open a blank window if there is no window with such a
name.
I am trying to organise a navigation structure between two windows with
content from the same host.. I have been trying the following:
|
by: Mark Broadbent |
last post by:
Hi guys, just going through remoting at the moment and a couple of questions
relating to .net in general has surfaced.
Firstly I have seen in the designer that for the namespace and many of its
associated classes of System.Runtime.Remoting are available, but certain
ones are not. A reference to System.Runtime.Remoting needs to be added to
make available all the unavailable ones. Now although I (think) understand
the concept that an...
|
by: martin |
last post by:
Hi,
I am a web page and a web user control. My web user control is placed in my
web page using the following directive
<%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx"
%>
The web user control contains the following server controls
|
by: Amelyan |
last post by:
I am struggling here trying to determine what is a good programming practice
as far as referencing your URLs.
When you use Response.Redirect, do you use
1) Hard-coded string -- Response.Redirect("MyPage.aspx");
2) Constants -- Response.Redirect(STRMyPage); // where input parameter
is -> const string STRMyPage = "MyPage.aspx";
3) Something entirely differnent?
| |
by: lwoods |
last post by:
Example:
$x=array('a'=>'ant','b'=>'boat');
$s='a';
$y='$s';
echo $x;
I want to echo the value of key 'a' by indirectly referencing it via the
variable $y. The above is NOT correct, I know.
|
by: Axel |
last post by:
Hi,
a question about something that seems very simple at first glance:
is it possible to reference other controls of a subform in a query
window without referencing through the parent form? I want to do this
as I want to use same subform on two different parent forms. Main
problem is that the subform is not part of the forms collection.
The only workaround I found was setting the query in code in the
|
by: HankD |
last post by:
Hi, I am having a problem with instantiating two custom objects so they
DO NOT point to the same memory location. What is happening is that
changes I am making to my object1 are changing object2. I beleive this
is because I set both to be equal to the same session variable. So when
I change the value in test1.name it updates test2.name as well as the
session variable itself. What I want to do is keep an "ORIGINAL" copy
of the data in case...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |