Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

JBUILD modes and additive values in QM

52 views
Skip to first unread message

jaya...@gmail.com

unread,
Mar 6, 2022, 10:18:27 PM3/6/22
to OpenQM
Hello:

I'm having trouble getting JBUILD to not add double quotes around numeric values. The reference manual lists additive values for various options - but no joy. Either I don't understand additive values or I'm not coding it correctly.

I'm running 3.4-15B and I do note there are changes in later releases (additional modes were added - I think). Still, I believe my version supports the desired mode.

Anyone know how to make this work? I'd supply my code but it's really just a question of function syntax. Thanks!

Martin Phillips

unread,
Mar 7, 2022, 4:20:07 AM3/7/22
to ope...@googlegroups.com

Hi,

 

There is a mode setting for JBUILD() that converts numeric strings to numbers but nothing to go in the reverse direction converting  numbers to quoted strings.

 

You would need to ensure that the item in the data collection is a string. The following quick example shows one way to do this…

c = collection()

c{'a'} = 123         ;* Save as number

c{'b'} = str(123)    ;* Save as string

display jbuild(c)

 

 

Martin

 

 

From: ope...@googlegroups.com <ope...@googlegroups.com> On Behalf Of jaya...@gmail.com
Sent: 07 March 2022 03:18
To: OpenQM <ope...@googlegroups.com>
Subject: JBUILD modes and additive values in QM

 

EXTERNAL EMAIL




--
You received this message because you are subscribed to the Google Groups "OpenQM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openqm+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openqm/1f734913-e51a-4e41-8bb5-a0c58cb7d26dn%40googlegroups.com.

================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy
================================

This communication and any attachments may contain confidential information of Rocket Software, Inc. All unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify Rocket Software immediately and destroy all copies of this communication. Thank you.

Martin Phillips

unread,
Mar 7, 2022, 4:52:44 AM3/7/22
to ope...@googlegroups.com

I mis-read the original email in this thread so my previous response did not resolve the problem.

 

JBUILD() normally uses the data type of the variables in the data collection to determine the JSON data type. If you have, for example, statement such as

   A = DYN<1>

where DYN is a dynamic array with field 1 containing a numeric value, variable A will be a string because field extraction is defined as returning a sting value. The program may go on to do arithmetic operations on this variable and the data type conversion needed will occur automatically as multivalue Basic uses type variant variables.

 

If you want the numeric value to be a number, the traditional way to convert a numeric string to a number is the rather odd

   A = DYN<1> + 0

 

QMBasic provides explicit type conversion functions that make this a bit clearer.

   A = NUMERIC(DYN<1>)

 

You could use this construct when saving numeric values in elements of a data collection but, if the JSON representation of your data collection is to treat all numeric strings as numbers, you can do

   JSON.STRING = JBUILD(COL, JB$NUM)

 

The JB$NUM token is defined in the KEYS.H include record.

 

 

Martin

 

From: ope...@googlegroups.com <ope...@googlegroups.com> On Behalf Of jaya...@gmail.com
Sent: 07 March 2022 03:18
To: OpenQM <ope...@googlegroups.com>
Subject: JBUILD modes and additive values in QM

 

EXTERNAL EMAIL




--

You received this message because you are subscribed to the Google Groups "OpenQM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openqm+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openqm/1f734913-e51a-4e41-8bb5-a0c58cb7d26dn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages