Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Force string value?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Yurii Rashkovskii  
View profile  
 More options Jul 22 2010, 4:59 pm
Newsgroups: comp.lang.mumps
From: Yurii Rashkovskii <yra...@gmail.com>
Date: Thu, 22 Jul 2010 13:59:42 -0700 (PDT)
Local: Thurs, Jul 22 2010 4:59 pm
Subject: Force string value?
Hi,

Is there any way to force GT.M not to treat a string with a canonical
number as a number? I.e. if I do SET x("380")="",x("3791")="", instead
of this order:

x(380)=""
x(3791)=""

I would like to get this one:

x("3791")=""
x("380")=""

I know the most obvious solution — prepend these key values with some
non-numeric character, but it will certainly cause some logical
complication for setting/reading/indexing. Is there any better
solution?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JJ  
View profile  
 More options Jul 22 2010, 8:47 pm
Newsgroups: comp.lang.mumps
From: JJ <jeffersonjj.nos...@hotmail.com>
Date: Fri, 23 Jul 2010 00:47:27 +0000 (UTC)
Local: Thurs, Jul 22 2010 8:47 pm
Subject: Re: Force string value?

Just curious but *why* would you want to do this?
--
JJ

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dahakon  
View profile  
 More options Jul 22 2010, 10:47 pm
Newsgroups: comp.lang.mumps
From: dahakon <n...@valid.com>
Date: 23 Jul 2010 02:47:09 GMT
Local: Thurs, Jul 22 2010 10:47 pm
Subject: Re: Force string value?

You can define a custom collation sequence and use it for globals and
local variables.

For more details, see the internationalization chapter of the
programmer's guide:
http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/chapter13.htm
l

Yurii Rashkovskii <yra...@gmail.com> wrote in news:3f18d6b8-af2f-4e43-
afad-12872a1d0...@q21g2000prm.googlegroups.com:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yurii Rashkovskii  
View profile  
 More options Jul 23 2010, 2:13 am
Newsgroups: comp.lang.mumps
From: Yurii Rashkovskii <yra...@gmail.com>
Date: Thu, 22 Jul 2010 23:13:02 -0700 (PDT)
Local: Fri, Jul 23 2010 2:13 am
Subject: Re: Force string value?
On Jul 22, 5:47 pm, JJ <jeffersonjj.nos...@hotmail.com> wrote:

> > x("380")=""

> > I know the most obvious solution   prepend these key values with some
> > non-numeric character, but it will certainly cause some logical
> > complication for setting/reading/indexing. Is there any better
> > solution?

> Just curious but *why* would you want to do this?

Phone prefixes. They aren't numbers, they are essentially strings that
happen to consist of numbers, therefore 3791 goes before 380.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yurii Rashkovskii  
View profile  
 More options Jul 23 2010, 2:14 am
Newsgroups: comp.lang.mumps
From: Yurii Rashkovskii <yra...@gmail.com>
Date: Thu, 22 Jul 2010 23:14:22 -0700 (PDT)
Local: Fri, Jul 23 2010 2:14 am
Subject: Re: Force string value?
On Jul 22, 7:47 pm, dahakon <n...@valid.com> wrote:

> You can define a custom collation sequence and use it for globals and
> local variables.

> For more details, see the internationalization chapter of the
> programmer's guide:http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/chapter13.htm

Yeah, I know about this (didn't try it yet, though), but isn't it a
region-wide setting? I just need this kind of "string enforcement"
only for some very few subscripts.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yurii Rashkovskii  
View profile  
 More options Jul 23 2010, 3:08 am
Newsgroups: comp.lang.mumps
From: Yurii Rashkovskii <yra...@gmail.com>
Date: Fri, 23 Jul 2010 00:08:06 -0700 (PDT)
Local: Fri, Jul 23 2010 3:08 am
Subject: Re: Force string value?
On Jul 22, 11:14 pm, Yurii Rashkovskii <yra...@gmail.com> wrote:

> Yeah, I know about this (didn't try it yet, though), but isn't it a
> region-wide setting

Or it can be global-wide, but can't be enforced on a particular
subscript or a value.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yurii Rashkovskii  
View profile  
 More options Jul 23 2010, 7:21 am
Newsgroups: comp.lang.mumps
From: Yurii Rashkovskii <yra...@gmail.com>
Date: Fri, 23 Jul 2010 04:21:08 -0700 (PDT)
Local: Fri, Jul 23 2010 7:21 am
Subject: Re: Force string value?
On Jul 22, 7:47 pm, dahakon <n...@valid.com> wrote:

> You can define a custom collation sequence and use it for globals and
> local variables.

> For more details, see the internationalization chapter of the
> programmer's guide:http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/chapter13.htm
> l

So I did this, quick-n-dirty version of the source code is available
at https://gist.github.com/7187e3c76ad7e39a49fd

The only problem with it is that even though it seems to work
perfectly well for storage & retrieval (you just have to prepend
subscript with $c(255)), any explicit or implicit ordering (say, $o)
has no idea about that and will effectively disrupt proper workflow,
UNLESS the key used in it is prepended with $c(255) itself so the
value becomes a "forced string" as well. Otherwise it will consider
provided key a number and next key will be the very first string key,
which is clearly not what what you want to get in this scenario. In my
case, I can workaround this by always prepending keys with that
$c(255) as I always have that information on whether this particular
subset of the global is a forced string or not. Also, as a side
effect, ZWR will hang on globals with forced strings.

So, I have mixed feelings about this solution. On one hand, it works,
on the other hand it causes some inconvenience (or, what's worse,
potentially hanging GT.M when the key is not prepended with that
prefix).

Anyway, thanks for the help everybody!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Julius Kavay  
View profile  
 More options Jul 23 2010, 8:43 am
Newsgroups: comp.lang.mumps
From: Julius Kavay <ka...@gmx.net.valid.address.changed.to.invalid>
Date: Fri, 23 Jul 2010 14:43:57 +0200
Local: Fri, Jul 23 2010 8:43 am
Subject: Re: Force string value?

Yurii Rashkovskii wrote:
> On Jul 22, 5:47 pm, JJ <jeffersonjj.nos...@hotmail.com> wrote:

>>> x("380")=""
>>> I know the most obvious solution   prepend these key values with some
>>> non-numeric character, but it will certainly cause some logical
>>> complication for setting/reading/indexing. Is there any better
>>> solution?
>> Just curious but *why* would you want to do this?

> Phone prefixes. They aren't numbers, they are essentially strings that
> happen to consist of numbers, therefore 3791 goes before 380.

if you really want this order  (3791 followed by 380) then
just append zeros or blanks to a fixed length.

Assuming, the longest prefix is 8 character long:

Variante a)
-----------
Kill ^Prefix
Set nul="00000000"
For pref=3791,380 Set ^Prefix($e(pref_nul,1,8)_$l(pref))=""

Set pref=""
For  Set pref=$O(^Prefix(pref)) Quit:pref=""  Write $e(pref,1,pref#10),!

^Prefix(379100004)=""
^Prefix(380000003)=""

Variante b)
-----------
Kill ^Prefix
Set spc="        "
For pref=3791,380 Set ^Prefix($e(pref_spc,1,8))=""

Set pref=""
For  Set pref=$o(^Prefix(pref)) Quit:pref=""  Write $p(pref," "),!

^Prefix("3791    ")=""
^Prefix("380     ")=""

Just for the curiosity, long time ago, I worked on a MUMPS system
where numbers with leading zeros were sorted by their length and
not by their value:

0,1,2,..8,9,00,01,02,..08,09,10,11,12,...98,99,000,001,002,..008,
009,010,011,012,...098,099,100,101,102 and so on.

It was perfect for article- or itemnumbers, bank accounts etc.

Regards and
have a nice day
Julius

--
(my real mail address ends with a .net tld)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Maury Pepper  
View profile  
 More options Jul 23 2010, 11:48 am
Newsgroups: comp.lang.mumps
From: "Maury Pepper" <mpepper_scram_s...@ieee.org>
Date: Fri, 23 Jul 2010 10:48:41 -0500
Local: Fri, Jul 23 2010 11:48 am
Subject: Re: Force string value?

A single space on the end will work and often is just what you want for output - if not, it's easy to remove.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »