concatenation

Blitz3D Forums/Blitz3D Beginners Area/concatenation

Doggie(Posted 2010) [#1]
SaveImage (TestImage,"test" +(Frame) +".bmp")
Will give me test1.bmp etc...
SaveImage (TestImage,imagename$+(Frame)+".bmp"
So how come this won't if I try to use a variable for the name in addition to a variable for which frame?


BoneStan(Posted 2010) [#2]
Works fine for me, make sure the variable is global.

Global imagename$ = "Picture"


_PJ_(Posted 2010) [#3]
Yeah make sure that you're declring strings and ints correctly too:

Compare:
A_Variable=5
AnotherVariable=6

Print A_Variable+AnotherVariable+".bmp"


Wih

A_Variable=5
AnotherVariable$="6"

Print Str(A_Variable)+AnotherVariable$+".bmp"



Doggie(Posted 2010) [#4]
imagename$ is global. I keep getting test.bmp1 test.bmp2 test.bmp3 instead of test1.bmp test2.bmp


Matty(Posted 2010) [#5]
It does work, I use similar things all the time.

I'm wondering though if your "imagename$" variable already has .bmp in it and you are appending the 2/3/4 etc on to it - and perhaps in your windows file folder view options you have known file type extensions hidden.

This works fine:

Function savemyimage(imagehandle,filename$,frame)
if imagehandle = 0 then 
     return -1 ;error 
else
     saveimage (imagehandle,filename$+str(frame)+".bmp")
endif
End Function 



Floyd(Posted 2010) [#6]
imagename$+(Frame)+".bmp" can't possibly produce test.bmp1 test.bmp2 etc.

You will have to show us some runnable code.


Doggie(Posted 2010) [#7]
Alright. I'm at work now but I'll get back to this in the a.m. cuz it don't seem to make anysense. I figure most likely it's somewhere else in the code that is doing it but I can't imagine why.


_PJ_(Posted 2010) [#8]
Somewhere you've got the (Frame) after the ".bmp" soudns pretty obvious, but that would appear to be the issue.
Might be related somewhere where you obtain an original filename that by default includes the extension, and you're not removing that extension to insert the frame variable?


Doggie(Posted 2010) [#9]
I was trying to change the animation name by opening a BlitzUI file requester and selecting a pic. Well, duh,it was assigning the full name of the file to imagename$...Fixed it by using an input box instead.
Still could use tips on how to do "rubberbanding" to make rects and circles or to grab screen areas and code to magnify an area of my imageblock and display it on a seperate imageblock without hogging the program till it slows to a crawl. Thanks y'all.

DOG


Matty(Posted 2010) [#10]
Rather than using an input box simply use the file requester and remove the all characters after and including the "." in the filename (if it exists), then append it back on.


Warner(Posted 2010) [#11]
Instead of using SaveFile, use "RunTimeError", "DebugLog" or just "Print" to check the filename that you are saving to.
Maybe you have the 'hide extensions for known file types' option checked in Explorer? Your file would be called:
test.bmp1.bmp
but explorer doesn't show the last ".bmp" part.
In Explorer->Tools->Folder options->View->Uncheck 'hide extentions for known file types'.


Doggie(Posted 2010) [#12]
Actually the input box works better than using a file requester. Somehow it just fits this program. I'm probably about done with it since basic scale and rotate commands in Blitz2d don't really work and I don't see much point in trying to do much more with it.


PowerPC603(Posted 2010) [#13]
This code procudes the correct results (Test1.bmp, Test2.bmp, ...):
Global ImageName$ = "Test"

For Frame = 1 To 10
	Print ImageName$ + Str$(Frame) + ".bmp"
;	Print MakeFileName$(ImageName$, Frame)
	Print ""
Next

WaitKey()
End



Function MakeFileName$(File$, Number)
	Return File$ + Str$(Number) + ".bmp"
End Function


If you want to use the function, just uncomment the commented "Print"-line and comment the other.

The function basically does the same as the stuff behind the Print command.


_PJ_(Posted 2010) [#14]
I have some functions somewhere (a combination of my own and some provided on code archioves) that deal with things like
Getting the Path to Parent Directory of a file (i.e path minus actual filename + extensin)
Getting the extension only
Getting the filename only

It's late for me now, but tomorrow I'll dig them out for you and post them here, they should be useful for this kind of stuff!