PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Logic with Numeric Multi_lines  (Read 356 times)

James Zukowski

  • Silver Member
  • ***
  • Posts: 41
    • View Profile
Logic with Numeric Multi_lines
« on: August 09, 2018, 03:20:08 PM »
I'm using a generated File Maint program to work on a file that has numeric fields in it. When I want to refer to these values in Logic procedures in a multi_line, I seem to get inconsistent results. Which of these should I actually use?

  • Field_Name
  • Field_Name.Ctl'Value
  • Field_Name$
  • Field_Name.Ctl'Value$

Thanks!
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Thomas Bock

  • Silver Member
  • ***
  • Posts: 39
    • View Profile
Re: Logic with Numeric Multi_lines
« Reply #1 on: August 10, 2018, 01:52:45 AM »
We use "Auto Refresh" in the header properties and Field_Name / Field_Name$ in the logic. This way you can keep a lean code. If you omit the header property, then you must use the control properties Field_Name.ctl'value($).

James Zukowski

  • Silver Member
  • ***
  • Posts: 41
    • View Profile
Re: Logic with Numeric Multi_lines
« Reply #2 on: August 10, 2018, 09:48:51 AM »
But if I have a numeric field variable, do I use the Field_Name or Field_Name$ in the procedures?
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 2972
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Logic with Numeric Multi_lines
« Reply #3 on: August 10, 2018, 10:02:05 AM »
If the control is set as number then use the numeric variable.

James Zukowski

  • Silver Member
  • ***
  • Posts: 41
    • View Profile
Re: Logic with Numeric Multi_lines
« Reply #4 on: August 10, 2018, 10:10:26 AM »
I guess that calls into question whether I should set up the control as Number if the data field is numeric. In the generated F/Ms, the Num_To_Str routine is called after reading the record, and Str_To_Num before being rewritten. Which suggests I should use the controls as strings, not numbers, even though the underlying file variable is numeric.

Clarification? Is this the way to go?
« Last Edit: August 13, 2018, 03:17:19 PM by jzukowski »
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

James Zukowski

  • Silver Member
  • ***
  • Posts: 41
    • View Profile
Re: Logic with Numeric Multi_lines
« Reply #5 on: August 16, 2018, 10:44:54 AM »
Does anyone have some clarification?
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Jane Raymond

  • Staff
  • Diamond Member
  • *****
  • Posts: 221
    • View Profile
    • PVX Plus Technologies
Re: Logic with Numeric Multi_lines
« Reply #6 on: August 16, 2018, 11:00:44 AM »
James,
If you want to effect a change that will be reflected in the control on the panel, use the control name. (This value will then be converted to the record field in the Str_to_num, so you're covered.)
Jane Raymond
Software Developer
PVX Plus Technologies Ltd.

James Zukowski

  • Silver Member
  • ***
  • Posts: 41
    • View Profile
Re: Logic with Numeric Multi_lines
« Reply #7 on: August 16, 2018, 11:07:33 AM »
Yes, that works as designed, but I want to be able to use the contents of that value (in this case a "Length") to determine the specifications for a different control.
Should I use a Numeric control for the file's numeric field? Or should I use num(Control$) and make it a non-Numeric control?
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Sebastiaan Fisscher

  • New Member
  • *
  • Posts: 22
    • View Profile
    • Astecom Business Software
Re: Logic with Numeric Multi_lines
« Reply #8 on: August 17, 2018, 03:14:50 AM »
Hi James:

You've got a number of questions here;

1 I'm using a generated File Maint program to work on a file that has numeric fields in it. When I want to refer to these values in Logic procedures in a multi_line, I seem to get inconsistent results. Which of these should I actually use?
* Example; your multi_line is called 'number.ctl', then you can change the value like:  number=10, if number=12 then {}. number.ctl'value=10 is also possible, but not necessary.
  (Be sure to have "Auto refresh" turned on in the panel properties like Thomas mentioned.)

2 I want to be able to use the contents of that value (in this case a "Length") to determine the specifications for a different control.
Should I use a Numeric control for the file's numeric field? Or should I use num(Control$) and make it a non-Numeric control?

It depends what kind of number you want to save. If it's a phone number then you ill need to make the multi_line alpha numeric, is it's a total amount of items or the price of an item it's perhaps better to use a numeric variable.
Checking the length of a numeric field will be like the following; *example; a=1234, print len(str(a)) will show you "4".

Wether or not you save numbers in numeric or alpha-numeric fields is entirely up to you. If you want to calculate costs of items, or any other calculation I'd suggest you save it as a numeric field. If it's only plain data that needs to be printed like phone numbers or adress numbers you're better off saving them in alpha-numeric fields.

Hope that helps you.

Jane Raymond

  • Staff
  • Diamond Member
  • *****
  • Posts: 221
    • View Profile
    • PVX Plus Technologies
Re: Logic with Numeric Multi_lines
« Reply #9 on: August 17, 2018, 08:54:10 AM »

James,

When a File Maintenance panel is generated, the controls for numeric fields are generated as string fields. There  are conversion routines (NUM_TO_STR, STR_TO_NUM) to keep the numeric field and its control string field synchronized. Whenever the record is read, the string field is synchronized, and whenever the user changes the field in the control, the numeric field is synchronized. If the field value is changed by the user entering data or by browsing, etc., the fields are synchronized, so it doesn't really matter which one you use.
However, if you are changing the value programatically, it is important to keep both synchronized, so you should set them both.
« Last Edit: August 17, 2018, 09:00:37 AM by Jane Raymond »
Jane Raymond
Software Developer
PVX Plus Technologies Ltd.

James Zukowski

  • Silver Member
  • ***
  • Posts: 41
    • View Profile
Re: Logic with Numeric Multi_lines
« Reply #10 on: August 17, 2018, 10:44:25 AM »
Quote
whenever the user changes the field in the control, the numeric field is synchronized. If the field value is changed by the user entering data or by browsing, etc., the fields are synchronized, so it doesn't really matter which one you use.
Jane, on this one, I beg to differ. The only place that I see the STR_TO_NUM being used in the F/M is at WRITE time. And I don't think *winproc knows whether it's supposed to maintain both values (though I haven't gone too deep into that). (NUM_TO_STR is used in FIND_REC, WRT (post-write), DISP_REC, and CLEAR_FIELDS.)
Which suggests, again, that everything be handled with the strings, and only the actual file contents are numeric.
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Jane Raymond

  • Staff
  • Diamond Member
  • *****
  • Posts: 221
    • View Profile
    • PVX Plus Technologies
Re: Logic with Numeric Multi_lines
« Reply #11 on: August 17, 2018, 11:07:32 AM »
James,
It's a good thing you beg to differ, since after looking at the code I discovered that my assumptions were wrong, and you are right.


BTW, *winproc only maintains the one value.
Jane Raymond
Software Developer
PVX Plus Technologies Ltd.

Thomas Bock

  • Silver Member
  • ***
  • Posts: 39
    • View Profile
Re: Logic with Numeric Multi_lines
« Reply #12 on: August 17, 2018, 11:14:48 AM »
I'm not sure, but I think I see your point.
The concept of the generator is to handle strings only. That is why it requires you to declare the numeric variables of your file in _numdef$. It is used for generating the numeric values for I/O operations on the fly. Otherwise these values would be lost.
But that shouldn't have any impact on your program logic. It should be possible to use numeric controls and "Auto Refresh". This way the generator logic will needlessly create those numeric variables itself.