IonicWind Software

Creative Basic => General Questions => Topic started by: KQ4TX on September 26, 2009, 09:06:04 AM

Title: RESOURSE FILES
Post by: KQ4TX on September 26, 2009, 09:06:04 AM

GENTLEMAN

I PURCHASED CREATIVE BASIC THINKING MAYBE BUT MAYBE THIS VERSION WOULD LET ME
RESOURSE IMAGE FILES AND WAV FILES INTO MY COMPILED PROGRAM. CREATIVE BASIC LOOKS JUST LIKE MY iBASIC PROGRAM WHICH WON'T LET ME RESOURSE BECAUSE IT IS A SHAREWARE VERSION. MY QUESION IS, HAS ANYONE TRIED TO RESOURSE FILES IN THIS VERSION. IS THERE
A FULL VERSION OF THIS PROGRAM THAT WILL LET ME SOLVE THIS PROBLEM.
THANKS
JOE
Title: Re: RESOURSE FILES
Post by: LarryMc on September 26, 2009, 09:13:50 AM
Did you read the Resouce Files section of the Creative Basic help file?

Larry
Title: Re: RESOURSE FILES
Post by: KQ4TX on September 26, 2009, 09:28:07 AM

YES iI DID AND IT SAID IF THIS IS A SHAREWARE VERSION RESOURSES COULD NOT BE USED.
THE AD DIDN'T SAID CREATIVE BASIC WAS A SHAREWARE VERSION EVEN THOUGH IT LOOKS JUST LIKE IBASIC STANDARD 2.02D. THE ONE GOOD THING ABOUT USING THIS PROGRAM
IS I CAN TALK TO ALL PRO'S OUT THERE.OH WELL IT WAS JUST 14 DOLLARS.
Title: Re: RESOURSE FILES
Post by: LarryMc on September 26, 2009, 09:35:51 AM
Although I don't use it I have CBasic 1.0.
It allows you to add resources to your .exe.

So, I'm not understanding why you say you can't.

Larry
Title: Re: RESOURSE FILES
Post by: KQ4TX on September 26, 2009, 09:43:51 AM

OK MR LARRY NOW I KNOW IT MUST BE ME. IF I GO TO THE MENU AND CLICK ON RESOURSE
AND GO TO TYPE SCALABLE IMAGE AND ENTER THE FILENAME AND PRESS ADD.
WHEN I COMPILE THE PROGRAM IT COMES UP WITH A ERROR, COMPILING RESOURSE.
WHAT AM I DOING WRONG?
Title: Re: RESOURSE FILES
Post by: LarryMc on September 26, 2009, 09:51:16 AM
Three questions?
Did you use Choose to select the image?
what was the extension of the image file?
what did you enter for the ID?

Larry
Title: Re: RESOURSE FILES
Post by: LarryMc on September 26, 2009, 09:57:47 AM
The two things that I can do to get that error message is leave the ID blank or enter a non-existant image file.

Larry
Title: Re: RESOURSE FILES
Post by: KQ4TX on September 26, 2009, 10:12:42 AM

I SENT A REPLY THAT DIDN'T POST.
OK LET ME INVESTIGATE AGAIN. THE MAIN THING IS IT SHOULD WORK AND THAT ALL I WANTED TO KNOW. IF NOT I'LL BE BACK
THANKS
JOE
Title: Re: RESOURSE FILES
Post by: LarryMc on September 26, 2009, 10:14:44 AM
Read the Help File

Larry
Title: Re: RESOURSE FILES
Post by: aurelCB on September 26, 2009, 12:28:54 PM
Yes best option is read help topic about resources and dont forget only in compiled (buildet) exe
file you can see how resource works not in runtime mode in editor when you test your program.

Aurel ;D
Title: Re: RESOURSE FILES
Post by: KQ4TX on September 27, 2009, 10:37:59 AM

OK  I GOT THE RESOURCE TO WORK FOR AN IMAGE
I HAD TO CHANGE MY PROGRAM FROM THIS PIC1= loadimage(GETSTARTPATH + "COOL18.JPG", @IMGSCALABLE )TO THIS PIC1= loadimage ("COOL18", @IMGSCALABLE ) THEN COMPILE.
ID=COOL18, TYPE = @IMGSCALABLE , FILENAME =SELECT FILE LOCATION,  PRESS THE ADD BUTTON.
NOW I WANT TO RESOURCE A WAV FILE.YOU SAID READ THE HELP FILE SO HERE IT IS
For example you may want to include wave files in your project and later load the sounds from the
resources using LOADRESOURCE. In this case it is recommended you use a string type identifier such as WAVE or SOUND as the custom type.

success = LOADRESOURCE(ID, Type, Variable)
Loads a resource from the executable and places either a copy of the resource, or an integer pointer to the resource, in the variable specified.
ID is either a numeric or string identifier to the resource, TYPE is a numeric or string type and it stores the info in 'variable.

I CHANGED MY PROGRAM FROM THIS
HANDLE = GETSTARTPATH  + "SH21.WAV"

TO THIS
HANDLE=  LOADRESOURCE("SH21",WAVE,"SND")
I'VE TRIED EVERY COMBINATION AND ALL I GET IS "ILLEGAL ASSIGNMENT" OR ERRORS,ETC
I USED SND AS MY VARIABLE
MAYBE SOMEONE CAN SOLVE THE PROBLEM
JOE






Title: Re: RESOURSE FILES
Post by: KQ4TX on September 27, 2009, 10:42:32 AM

BY THE WAY, SORRY I MISSPELLED RESOURCE IN THE TOPIC.
JOE
Title: Re: RESOURSE FILES
Post by: LarryMc on September 27, 2009, 01:53:52 PM
So let's see if I understand you correctly.
You are trying to load the resource with:
HANDLE=  LOADRESOURCE("SH21",WAVE,"SND")
from the help file:
Quotesuccess = LOADRESOURCE(ID, Type, Variable)
What value did you define WAVE to be?  The help file states it has to be a number over 255

The help file also says:
QuoteIf 'variable' is a STRING (or ISTRING) variable the contents of the resource will be copied into the string.
"SND" is not a string variable; it is a literal string.
A string variable would be defined this way:
def snd as string
So your statement would be more correct if you had it as:
def snd as string
HANDLE=  LOADRESOURCE("SH21",WAVE,SND)

But unless your wave file is 255 or less bytes long it still isn't going to work because a string variable can only hold 255 characters.
You're either going to have to define an ISTRING large enough to hold it or use a MEMORY variable.

That's about as much as I can help you.
If it were me I would handle it exactly the way I know it would work already(the way I previously explained to you) and let it go at that.

Good luck.

Larry

Title: Re: RESOURSE FILES
Post by: SnarlingSheep on September 28, 2009, 07:17:31 AM
Here's what you need to do.
Add a resource and use these values:
ID= 100, Type= Custom, Custom Type= WAVE
Then select your wav file and click the Add button.

Here's what should be a working example:

DEF win:WINDOW
DEF mySound:MEMORY
DEF success:INT

window win,100,100,245,202,@caption|@minbox,0,"Wave Resource Test",MainWndProc
control win,"B,Play,84,142,72,24,0x800000,1"
control win,"B,Exit,160,142,75,24,0x800000,2"
centerwindow win

'success will just tell you if the resource was loaded.
'100 is the resource ID.
'WAVE is the Custom Type.
'mySound is the memory variable the sound data is loaded into.
success = loadresource(100,"WAVE",mySound)
if success = 0
messagebox win,"Unable to load Wave Resource", "Wave Resource Test"
endif

run = 1
waituntil run = 0
'Make sure to free the MEMORY variable
freemem mySound
closewindow win
end

MainWndProc:
select @class
case @idcontrol
select @controlid
case 1
playwave mySound,@SNDASYNC
case 2
run = 0
endselect
case @IDDESTROY
run = 0
case @idclosewindow
run = 0
endselect
return
Title: Re: RESOURSE FILES
Post by: KQ4TX on September 28, 2009, 02:11:54 PM

OK SNARLINGSHEEP YOU CAME TO SAVE THE DAY.
AFTER 150 VIEWS I WOULD THINK SOMEONE WOULD HAVE THE ANSWER.
THANKS SO MUCH
LET ME TRY IT OUT. IT DOES MAKE SENSE. I WAS CLOSE BUT STILL LOST
I'M USING DOZENS IF IMAGES AND WAV FILES IN THIS PROJECT I'M WORKING ON.
I THOUGHT IT WOULD BE NICE TO PLACE THEM INTO MY COMPILED PROGRAM.
I'LL GET BACK IF I DON'T GET IT WORKING.
THANKS AGAIN
JOE