News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Loading numbers

Started by jj2007, September 07, 2022, 11:09:02 PM

Previous topic - Next topic

jj2007

Quote from: hutch-- on September 07, 2022, 09:50:24 AMWhile putting strings into a text file makes sense, rather than have to convert numbers both ways, having a structure of your own design with as many numbers as you wish to preserve as structure members is fast to load, save and internally process. This is why I use a binary file for numbers that must be preserved.

include \masm32\MasmBasic\MasmBasic.inc         ; download
SALES STRUCT
  sName$        db 20 dup(?)
  sNumber       dd ?
  sItemPrice    REAL4 ?
  sItemTax      REAL4 ?
  sAvgWeight    REAL4 ?
  sTotalWeight  REAL4 ?
SALES ENDS

  Init
  Print cfm$("#  Price\tTax\tWeight\tItem\n")   ; describe the records in the first line
  Recall "Sales.dat", sales() As SALES
  For_ ecx=0 To eax-1
        PrintLine Str$(ecx+1), Str$("  %4f\t", sales(ecx, sItemPrice)), Str$("%3f\t", sales(ecx, sItemTax)), Str$("%i\t", sales(ecx, sAvgWeight)), addr sales(ecx, sName$)
  Next
EndOfCode


Output (using the attached Sales.dat):
#  Price        Tax     Weight  Item
1  100.00       23.5    5       Vacuum cleaner
2  20.00        3.45    2       Accessories
3  50.00        6.45    22      Item #3