News:

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

Main Menu

RinstrX returns an index (for use with file extensions)

Started by jj2007, January 23, 2024, 12:20:01 PM

Previous topic - Next topic

HSE

Equations in Assembly: SmplMath

jj2007

Quote from: HSE on January 24, 2024, 10:13:21 AM.jpeg and .json files are very common now. Is the point necessary?

Quote from: HSE on January 24, 2024, 12:47:17 PMNo. Exactly here. Perhaps you don't have an answer.

Oh... now I get it: "point"="dot". So you mean this case:
  test ecx, RinstrX("This is a test.json", 1, .xls, .mdb, .json, .wk)
  inkey str$(eax), " is the index by RinstrX", 13, 10

Is the dot necessary?

test ecx, RinstrX("C:\XlsJsonJpegEtcFolder\MyFoto.jpeg", 1, .xls, .mdb, .Json, .Jpeg, .wk)
Guess what it would return without the dot...

HSE

Quote from: jj2007 on January 24, 2024, 01:01:23 PMOh... now I get it: "point"="dot".

D**m. But perfectly valid in pseudo-english  :biggrin:  :biggrin:

Quote from: jj2007 on January 24, 2024, 01:01:23 PMIs the dot necessary?

Ok. Perhaps English problem too. Look like, including the "dot", RinstrX is not so useful in 32 bits. Is posible to make modifications to recognice 4 characters instead of 3?
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on January 24, 2024, 08:31:38 PMIs posible to make modifications to recognice 4 characters instead of 3?

No need to modify the RinstrX macro :cool:

test ecx, RinstrX("C:\HectorsFiles\MyFoto.HSEpic", 1, .xls, .hsepic, .mdb, .Json, .Jpeg, .wk)
js NoSuchExtension

Returns index 1 (the "1" before .xls sets case-insensitive mode).

HSE

RinstrX("file1.xlsx",1,.xls,.xlsx,.doc,.docx,.htm,.html)  ?
Equations in Assembly: SmplMath

jj2007

  test ecx, RinstrX("file1.xslx",1,.xsl,.xslx,.doc,.docx,.htm,.html)
  print str$(eax), " is the mode 1 index by RinstrX", 13, 10

Works fine, as long as you respect the order first 3-byte, then 4-byte extension.

TimoVJL

a good point, as dot is just a dot and point have a larger meaning.
Quotea small, round spot that is used in numbers to separate whole numbers from parts of numbers:
May the source be with you

jj2007


HSE

Quote from: jj2007 on January 24, 2024, 09:38:59 PMWorks fine, as long as you respect the order first 3-byte, then 4-byte extension.

:thumbsup: Perfect.


Sorry, I was thinking in super fast comparison:
mov eax, 'xlsx'
push eax
...
pop eax
.if eax == extension
  ...
.endif
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on January 24, 2024, 10:44:57 PMI was thinking in super fast comparison

Less reliable (see examples above), and I doubt you'd ever use it in a speed-critical innermost loop ;-)